๐ Step-by-Step Server Configuration Guide
๐งญ Step 1: Navigate to the required directory
cd /etc/nginx/sites-enabled
๐งน Step 2: Delete the default configuration file
sudo rm default
โ๏ธ Step 3: Create a new configuration file
sudo nano default
Paste the following code inside the nano editor:
server {
listen 80;
server_name yourdomain.com; # Replace with your domain
location / {
if ($host = yourdomain.com) {
proxy_pass http://23.94.233.79:3008; # Replace with your Node.js app's port
}
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;
}
}
- โก๏ธ Save the file: Press CTRL + O to save, then Enter, and CTRL + X to exit nano.
โ Step 4: Test and restart NGINX
sudo nginx -t
sudo systemctl restart nginx
๐ Step 5: Install Certbot for HTTPS (SSL)
sudo apt install certbot python3-certbot-nginx
๐ Step 6: Obtain SSL Certificate
sudo certbot --nginx -d yourdomain.com
Now, your Node.js app should be accessible via https://yourdomain.com
with a valid SSL certificate! ๐