Deploy Web Application with Nginx, Domain, DNS, Port Forwarding on Google Compute Engine or any vps



Deploy Web Application with Nginx, Domain, DNS, Port Forwarding on Google Compute Engine or any vps

Deploy Web Application with Nginx, Domain, DNS, Port Forwarding on Google Compute Engine or any vps

Deploy Web Application with Nginx, Domain, DNS, Port Forwarding on Google Compute Engine or any vps.

Here is the Notes :

sudo apt update && sudo apt upgrade -y
sudo apt install nginx && sudo apt install nodejs npm && sudo npm install pm2 -g

# Create a Config – inside site-available –
sudo nano /etc/nginx/sites-available/noads.vip.conf

server {
listen 80;
server_name noads.vip www.noads.vip;

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;
}
}

# Move the File into site enable –
sudo ln -s /etc/nginx/sites-available/noads.vip.conf /etc/nginx/sites-enabled/

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl status nginx
sudo systemctl reload nginx
sudo netstat -tuln | grep -E ’80|443′ # Check if Nginx is listening

# Uncomment the next two lines if you want to set ufw default rules
# sudo ufw default deny incoming
# sudo ufw default allow outgoing

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status # Check Firewall & status

sudo nginx -t # Check if there are any errors

# Update Domain’s DNS
# A Record —— host/@ —— IP Address —— auto
# A Record —— host/www —— IP Address —— auto
# A Record —— host/api —— IP Address —— auto

# Add SSL Certificate
sudo apt install certbot python3-certbot-nginx
sudo certbot –nginx -d noads.vip -d www.noads.vip
sudo certbot renew # Automate the process and schedule for renewal. Consider a Cron Job
sudo certbot certificates # Check all available SSL certificates

# Disable other routes
sudo nano /etc/nginx/sites-available/default_server

server {
listen 80 default_server;
listen [::]:80 default_server;
return 444;
}

sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/default_server /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx