Back to blog
May 23, 2026Guides

How to Set Up Nginx Reverse Proxy

Proxy Node.js, Docker, or other apps through Nginx with WebSocket support and SSL on your VPS.

How to Set Up Nginx Reverse Proxy

A reverse proxy lets Nginx accept public HTTP/HTTPS traffic and forward it to backend apps (Node.js on port 3000, Docker containers, Python APIs). Essential for production deployments on a Hiddence VPS.

Prerequisites

  • Nginx installed and running
  • Backend app listening on localhost (e.g. 127.0.0.1:3000)
  • Domain pointed to your VPS (for SSL)
  • Ports 80 and 443 open in firewall

Basic reverse proxy config

Create a site config for your domain:

bash
server {
    listen 80;
    server_name app.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

sudo nginx -t && sudo systemctl reload nginx

WebSocket support

Required for Socket.io, many dashboards, and realtime apps:

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

Add HTTPS with Certbot

After HTTP works, issue a free certificate:

bash
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d app.yourdomain.com

# Certbot will update your server block for SSL automatically

Tips

  • Use proxy_buffering off for streaming/SSE if needed
  • Set client_max_body_size for file uploads
  • Run multiple backends on different subdomains
  • Use upstream blocks for load balancing multiple backends
  • Check error.log if you get 502 Bad Gateway