Configuration Server
Now let's configure the server to run the application.
Update & Download Packages
Update system
apt update && apt upgrade -d -y
Install Nginx
apt install nginx -y
Install sudo
apt install sudo -y
Install NodeJS 20
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\
apt install -y nodejs
Install pnpm
npm i pnpm -g
Install Docker
https://docs.docker.com/engine/install/debian/ (opens in a new tab)
Swap Memory
Swap memory is a space on a disk that is used when the amount of physical RAM memory is full. When a Linux system runs out of RAM, inactive pages are moved from the RAM to the swap space.
Configuration Nginx
Create config file
Go to the /etc/nginx/sites-available
directory and create a new file vitnode.conf
with the following content:
server {
listen 443 ssl http2;
ssl_certificate /etc/nginx/sites-available/ssl/cert-vitnode.pem;
ssl_certificate_key /etc/nginx/sites-available/ssl/key-vitnode.pem;
server_name frontend.vitnode.com www.frontend.vitnode.com;
# Redirect from www to non-www
if ($host = www.frontend.vitnode.com) {
return 301 https://frontend.vitnode.com$request_uri;
}
location / {
proxy_pass http://localhost:3000;
proxy_set_header X-Forwarded-Host $host;
}
}
server {
listen 443 ssl http2;
ssl_certificate /etc/nginx/sites-available/ssl/cert-vitnode.pem;
ssl_certificate_key /etc/nginx/sites-available/ssl/key-vitnode.pem;
server_name backend.vitnode.com www.backend.vitnode.com;
# Redirect from www to non-www
if ($host = www.backend.vitnode.com) {
return 301 https://backend.vitnode.com$request_uri;
}
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Forwarded-Host $host;
}
}
server {
listen 80;
server_name frontend.vitnode.com www.frontend.vitnode.com backend.vitnode.com www.backend.vitnode.com;
return 301 https://$server_name$request_uri;
}
Change frontend.vitnode.com
to your domain for the frontend and backend.vitnode.com
to your domain for the backend.
Finish configuration
Create a symbolic link to the sites-enabled
directory:
ln -s /etc/nginx/sites-available/vitnode.conf /etc/nginx/sites-enabled/
Create a directory for SSL certificates:
mkdir /etc/nginx/sites-available/ssl
Remove the default configuration:
rm /etc/nginx/sites-enabled/default &&\
rm /etc/nginx/sites-available/default
Upload SSL certificate
Open the /etc/nginx/sites-available/ssl
directory and upload:
- SSL certificate -
cert-vitnode.pem
, - Key -
key-vitnode.pem
Restart Nginx
systemctl restart nginx
===============================
Allow Nginx through the firewall
===============================
Configuration Server
Now let's configure the server to run the application.
Update & Download Packages
Install Docker
https://docs.docker.com/engine/install/debian/ (opens in a new tab)
Swap Memory
Swap memory is a space on a disk that is used when the amount of physical RAM memory is full. When a Linux system runs out of RAM, inactive pages are moved from the RAM to the swap space.