====== Reverse Proxy - NGINX Reverse Proxy - Passing Request Headers ======
By default, NGINX modifies two header fields in proxied requests, “Host” and “Connection”, and eliminates the header fields whose values are empty strings.
* “Host” is set to the value of the **$proxy_host** variable, and
* “Connection” is set to close.
To change these settings, as well as modify other header fields, use the **proxy_set_header** directive.
* This directive can be specified in a location or higher.
* It can also be specified in a particular server context or in the http block.
For example:
location /some/path/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8000;
}
**NOTE:** In this configuration the “Host” field is set to the $host variable.
----
===== To prevent a header field from being passed to the proxied server =====
Set it to an empty string as follows:
location /some/path/ {
proxy_set_header Accept-Encoding "";
proxy_pass http://localhost:8000;
}
----