Forwarding Headers & Client IP
Learn how Nginx rewrites request headers when proxying, and how to preserve the original client information for upstream applications.
Why Headers Matter
When Nginx acts as a reverse proxy, the upstream server only sees a connection coming from Nginx, not the real client. Without extra configuration, the backend loses the visitor's original IP, host, and protocol.
To keep this information, Nginx must forward headers describing the original request.
The Default Host Header
By default Nginx may pass the upstream server's address as the Host header. Many apps rely on the original host for routing or building absolute URLs.
Set it explicitly so the backend sees what the client requested:
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
}All lessons in this course
- Configuring Simple Reverse Proxy
- Upstream Servers & Load Balancing
- Proxy Buffering & Caching
- Forwarding Headers & Client IP