Reverse proxy

Reverse proxy to a local app

3 min · updated June 16, 2026

The single most common Nginx job: an app (Node, Python/Gunicorn, Go, Rails…) listens on a local port, and Nginx sits in front of it on port 80/443. The trap is forgetting the forwarded headers — without them the app logs Nginx’s IP and thinks every request is plain HTTP.

server {
    listen 80;
    server_name example.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;
        proxy_set_header X-Forwarded-Host  $host;

        proxy_read_timeout 60s;
    }
}

Key points:

Putting the repeated proxy_set_header lines in a file like /etc/nginx/proxy_params and include proxy_params; inside the location keeps every proxy block consistent.

Apply it:

sudo nginx -t && sudo nginx -s reload

← All snippets