Server configuration
Installation Steps
Section titled “Installation Steps”-
Update Your Server
sudo apt update && sudo apt upgrade -y -
Install Node.js & npm
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -sudo apt install -y nodejsnode -vnpm -v -
Install Docker & Docker Compose
sudo apt install -y apt-transport-https ca-certificates curl software-properties-commoncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgecho "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt updatesudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugindocker --versiondocker compose version -
Start Docker
sudo systemctl enable dockersudo systemctl start docker -
Setup Nginx as Reverse Proxy
sudo apt install nginx -ysudo nano /etc/nginx/sites-available/payload.conf -
Add the following configuration
server {server_name yourdomain.com;location /_next/static/ {add_header Cache-Control "public, max-age=31536000, immutable";proxy_pass http://nextjs_app;}location / {proxy_pass http://localhost:3000;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection 'upgrade';proxy_set_header Host $host;proxy_cache_bypass $http_upgrade;}} -
Now run nginx server
sudo ln -s /etc/nginx/sites-available/payload.conf /etc/nginx/sites-enabled/sudo nginx -tsudo systemctl restart nginx