Home / Hosting & Cloud / Reverse Proxy Node.js

Hosting & Server

Reverse Proxy Nginx in front of Node.js: the complete guide

by the team UseStackPulse Updated on August 30, 2026 9 min reading

Node.js is not made to be exposed directly on the Internet. Nginx in reverse proxy manages SSL, compression and websockets for you.

Advertising / AD Leaderboard 728×90

Reverse Proxy Basic Configuration

server {
    listen 80;
    server_name monapp.com;

    location / {
        proxy_pass http://127.0.0.1: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;
    }
}

Enable SSL with CertBot

sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d monapp.com

Tip: Upgrade and Connection headers are essential for websockets (socket.io) to work properly through the proxy.

Advertising / AD In-article 336×280

frequently asked questions

Do you need PM2 in addition to Nginx?

Yes, PM2 handles the node.js (automatic restart, logs) process while nginx handles incoming HTTP/HTTPS traffic.

Should port 3000 remain open publicly?

No, it must remain accessible only locally (127.0.0.1); Only Nginx must be exposed on ports 80/443.

Scroll to top