Issue with proxy_set_header

Rt Ibmer rtibmx at yahoo.com
Sat Jun 28 00:10:21 MSD 2008


I was having a problem where values I was setting using proxy_set_header in higher directives were getting lost when trying to use proxy_set_header in lower directives to add additional information.

Then I found this in the documentation, which explains the behavior I was seeing:

  "proxy_set_header directives issued at higher levels are only inherited when no proxy_set_header directives have been issued at a given level."

The challenge I have, however, is that I really would like to be able to use proxy_set_header at a lower level directive to **ADD** those headers to headers I set in higher levels, rather than having this replace it.  Is there a way to do this or a directive to specify to override this behavior, or perhaps another way to set the headers instead of using proxy_set_header?

The reason for this is that I use include files in my configuration to replicate common settings between my SSL and non-SSL areas of the site, like this:

server {
        listen       80;
        server_name  localhost;
        include      main.conf;
    }

 server {
        listen       443;
        server_name  localhost;

        proxy_set_header        X-Protocol      https;

        ... ssl key and other config settings here ...

        include      main.conf;

     }

Then inside my main.conf I use proxy_set_header to set various headers, proxy_pass and other common nginx configs.

So as you can see from the above, I want to have common headers set in main.conf but still be able to add some custom headers (such as X-Protocol shown in the sample above).

Is there a workaround or a better approach to this? Thank you!!




      






More information about the nginx mailing list