proxy_set_header on HTTP or Server level

stmx38 nginx-forum at forum.nginx.org
Fri Aug 30 17:03:57 UTC 2019


Hello,

We recently made some order in our configuration to make it cleaner and
readable.
We have moved all reverse proxy related parameters on the HTTP level from
the vhosts locations:
----
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  proxy_read_timeout 65;
  proxy_send_timeout 65;
  proxy_connect_timeout 30;
  proxy_buffering off;
  proxy_buffers 8 64k;
  proxy_buffer_size 64k;
  proxy_busy_buffers_size 128k;
  proxy_http_version 1.1;
  proxy_intercept_errors off;
----
As a result we got some issue with the at leas some of them:
----
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
  proxy_set_header Host $http_host;
----
As per documentation -
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header:
Context:	http, server, location

> These directives are inherited from the previous level if and only if
there are no proxy_set_header directives defined on the current level.
Does it mean that if at least one of the proxy_set_header is defined on
location level we should define all other on this level because it broke
inheritance?

Per our experience, these directives only work on location level. They do
not apply when we set them up on HTTP or Server level.

Why may be wrong with our configuration?

Thank you!

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,285462,285462#msg-285462



More information about the nginx mailing list