Proxy Headers and Pass Through

1 min read

Authors
banner

Proxy Headers and Pass Through

Essential Headers

Always forward these headers to backends:

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;

Header Meanings

HeaderValuePurpose
Host$hostOriginal host requested
X-Real-IP$remote_addrReal client IP
X-Forwarded-For$proxy_add_x_forwarded_forFull IP chain
X-Forwarded-Proto$schemehttp or https

Why Important?

Backend needs to know:

  • Original domain - For virtual hosts
  • Real client IP - For logging, auth
  • Protocol - For redirects, HSTS
  • Proxy chain - For security

Complete Example

server {
    location / {
        proxy_pass http://backend:3000;

        # Essential headers
        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;

        # Connection settings
        proxy_set_header Connection "";
        proxy_http_version 1.1;
    }
}

Headers passed!

© 2025 Vijay Rajendran