Nonstandard Response Headers
Brendan Schwartz
bschwartz at tropist.com
Sun Jan 20 23:45:39 MSK 2008
On Dec 29, 2007 5:48 PM, Evan Miller <emmiller at gmail.com> wrote:
>
> Brendan Schwartz wrote:
> > Is there a way to get Nginx to send nonstandard response headers (e.g.
> > "User-Header"); it looks like they're being filtered.
> >
> > Thanks,
> > Brendan
>
> Check out the proxy_pass_header directive.
>
> http://wiki.codemongers.com/NginxHttpProxyModule#proxy_pass_header
>
> Evan
>
This doesn't seem to be working for me. Here's an example of what I'm
trying to accomplish:
I have a local backend that returns a response that includes
X-Accel-Redirect, Authorization, and Some-Other-Header headers among
others.
And I have a /remote-proxy location whose job it is to proxy the
X-Accel-Redirect to a remote server.
See example configuration below.
I would like the proxy-pass request to the remote server to include
the Authorization and Some-Other-Header headers that were returned in
the local backend upstream response.
I've tried to use the proxy_pass_header directive, but haven't had
much luck as my "custom" headers aren't being passed to the remote
proxy server.
Am I using these directives correctly? Is what I'm trying to do impossible?
Thanks,
Brendan
---------------------------------------------------------------------
server {
# standard config ...
location /remote-proxy/ {
internal;
proxy_set_header X-Real-IP $remote_addr;
# needed for HTTPS
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host remote.server.com;
proxy_redirect false;
proxy_max_temp_file_size 0;
rewrite ^/remote-proxy/(.*)$ /$1 break;
proxy_pass https://remote.server.com;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
# needed for HTTPS
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
proxy_max_temp_file_size 0;
proxy_pass_header Authorization;
proxy_pass_header Some-Other-Header;
proxy_pass http://local_backend_upstream;
}
}
More information about the nginx
mailing list