| Syntax: | proxy_set_header field value |
| Default: | Host $proxy_host Connection close |
| Context: | http server location |
| Reference: | proxy_set_header |
This directive allows to redefine and to add some request header lines which will be transferred to the proxied server.
As the value it is possible to use a text, variables and their combination.
proxy_set_header directives issued at higher levels are only inherited when no proxy_set_header directives have been issued at a given level.
By default only two lines will be redefined:
proxy_set_header Host $proxy_host; proxy_set_header Connection Close;
The unchanged request-header "Host" can be transmitted like this:
proxy_set_header Host $http_host;
However, if this line is absent from the client request, then nothing will be transferred.
In this case it is better to use variable $host, it's value is equal to the name of server in the request-header "Host" or to the basic name of server, if there is no line:
proxy_set_header Host $host;
Furthermore, it is possible to transmit the name of server together with the port of the proxied server:
proxy_set_header Host $host:$proxy_port;
If value is empty string, than header will not be sent to upstream. For example this setting can be used to disable gzip compression on upstream:
proxy_set_header Accept-Encoding "";