add_header isn't taking effect

Michael Shadle mike503 at
Sat Aug 18 22:44:05 UTC 2012

This block basically works like a charm, passes the upstream headers
from proxy_pass_header as expected, but the add_header doesn't seem to
work no matter what. add_header is what I use upstream to add the
headers like X-Hostname-Proxy.

But I want to add a header local to this block. Ideas? I don't see
anything in the wiki saying this is invalid. It says it is valid in
location, server, etc blocks, which is what this is... :p

location ^~ /foo/bar {
        proxy_pass http://sites:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass_header Server;
        proxy_pass_header Expires;
        proxy_pass_header X-Hostname-Proxy;
        proxy_pass_header Access-Control-Allow-Origin;
        add_header FOO "bar";
        add_header FOO2 bar2;

More information about the nginx mailing list