Welcome! Log In Create A New Profile

Advanced

Re: Preserving all original request headers through a proxy_pass ?

Maxim Dounin
December 06, 2010 08:32PM
Hello!

On Mon, Dec 06, 2010 at 04:15:45PM -0800, Rasmus Lerdorf wrote:

> On 12/6/10 3:46 PM, Eugaia wrote:
> > Hi,
> >
> > On 07/12/2010 01:25, Rasmus Lerdorf wrote:
> >> I'm probably being a bit lazy here, I have only skimmed the code, but is
> >> there a way to bounce all original request headers through a proxy_pass
> >> prefixed with X-Orig-* or something like that?
> >>
> >> One reason for wanting to do this is for proxy detection. Common
> >> headers that are important to preserve are HTTP_X_FORWARDED, HTTP_VIA
> >> and HTTP_PROXY_CONNECTION.
> > Yes, you can use the proxy_set_header directive
> > (http://wiki.nginx.org/HttpProxyModule#proxy_set_header).
> >
> > e.g.
> >
> > proxy_set_header NAME $value;
> >
> > You can obviously choose anything for NAME, including X-Orig-..., and
> > the values can be static strings or generated using variables.
>
> Well, the key word was "all" in the question. I know I can set
> individual ones. I essentially want:
>
> proxy_set_header X-Orig-* $http_*
>
> Since I don't know what the full set might be.

Short answer:

No.

Long answer:

There is no way to pass all headers prefixed. On the other hand,
nginx passes most of the headers to upstream by default (with
their original names), and the only headers which are mungled by
default are Host, Connection, Keep-Alive, Expect (note that this
list a bit longer when proxy_cache is used, see [1]).

So you actually need to pass only original values of these headers
(plus ones you've mangled yourself via proxy_set_header
directive). Or even don't pass anything special at all as long as
you've not mangled headers critical for your task.

[1] http://mdounin.ru/hg/nginx-vendor-current/file/f6fa6099ee59/src/http/modules/ngx_http_proxy_module.c#l508

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Preserving all original request headers through a proxy_pass ?

Rasmus Lerdorf December 06, 2010 06:32PM

Re: Preserving all original request headers through a proxy_pass ?

Eugaia December 06, 2010 06:48PM

Re: Preserving all original request headers through a proxy_pass ?

Rasmus Lerdorf December 06, 2010 07:20PM

Re: Preserving all original request headers through a proxy_pass ?

Maxim Dounin December 06, 2010 08:32PM

Re: Preserving all original request headers through a proxy_pass ?

elgreco December 30, 2010 04:56PM

Re: Preserving all original request headers through a proxy_pass ?

Maxim Dounin December 30, 2010 06:32PM

Re: Preserving all original request headers through a proxy_pass ?

elgreco December 31, 2010 03:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 306
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready