Nonstandard Response Headers

Manlio Perillo manlio_perillo at libero.it
Mon Jan 21 00:07:48 MSK 2008


Brendan Schwartz ha scritto:
> 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;

Here, instead of using a rewrite, try with

         proxy_pass https://remote.server.com/remote-proxy/


>     }
> 
>     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;
> 
>    }
> }
> 


I'm not sure to understand what you are trying to do.
But try with:

        set $authorization upstream_http_authorization;
        set $some_other upstream_http_some_other_header;

in the / location

and:

        proxy_set_header Authorization $authorization;
        proxy_set_header Some-Other-Header $some_other;

in the remote-proxy location


However I'm rather sure that this will not work :).


> 



Manlio Perillo





More information about the nginx mailing list