Objective:
Set up a Node.js app running on one EC2 instance (backend) and access it only through another EC2 instance acting as an NGINX reverse proxy.
Implementation
Step 1: Setup Web Server (Node.js App)
-
Launched a new EC2 instance named Banked server.
-
Installed Node.js.
-
Created a simple app that listens on port 5000:

Step 2: Setup Reverse Proxy (NGINX Server)
-
EC2 Name:
Nginx -
Installed NGINX
sudo apt update sudo apt install nginx -
Configuration:
sudo nano /etc/nginx/sites-available/default
server {
listen 80;
location / {
proxy_pass http://<WEB_SERVER_PUBLIC_IP>:5000;
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;
}
}
sudo systemctl restart nginx

Step 3: Point Domain to NGINX
On domain provider (e.g., Namecheap), added an A record:

Final Results

✅ Domain Working
-
Visit:
http://dheerengaud.rest -
Flow: Domain → NGINX → WebServer (port 5000)
✅ NGINX Public IP Working
-
Visit:
http://<nginx-ip> -
Flow: IP → NGINX → WebServer (port 5000)
Direct Web Server Access Blocked
-
Visit:
http://<webserver-ip>:5000 -
Blocked for public access by security group rules
Conclusion
With this setup:
-
Users access your domain → hits NGINX → securely forwards to Node.js
-
Your backend is safe, scalable, and flexible for future upgrades