Editing headers in both directions

Toni Mueller support-nginx at oeko.net
Mon Mar 29 15:49:01 MSD 2010


Hello Maxim,

On Mon, 29.03.2010 at 15:09:42 +0400, Maxim Dounin <mdounin at mdounin.ru> wrote:
> On Mon, Mar 29, 2010 at 12:23:56PM +0200, Toni Mueller wrote:
> > I'd like to say something like
> > 
> > rewrite_header <headername> <direction> ...
> > 
> > where "..." is the same stuff as in the "rewrite" directive.
> > 
> > I've started taking a close look at ngx_http_rewrite_module.c, but
> > after reading some here
> > http://www.evanmiller.org/nginx-modules-guide.html, I found that I'm
> > most likely going down the wrong path. At least, I don't see how the
> > functionality I want fits into Evan's taxonomy of "handler", "filter",
> > and "upstream" modules.
> > 
> > Some guidance would be MUCH appreciated!
> 
> You have to implement:
> 
> 1. Rewriting of outgoing headers via header filter.  This should 
> be more or less trivial, see various header filters for examples, 
> e.g. src/http/modules/ngx_http_headers_filter_module.c.
> 
> 2. Rewriting of incoming headers.  This may be done via variable 
> and something like
> 
>     proxy_set_header Cookie $your_variable_with_rewritten_cookie;
> 
> in config (like it's done with X-Forwarded-For and 
> $proxy_add_x_forwarded_for variable).

thanks for the idea. This clears some dust up for me, but I'm still not
sure about how to do this because I need the full expressional power of
the "rewrite" module, only on arbitrary headers. That's why I initially
looked at "rewrite". I'll see whether I can meld the functionality of
these two modules.

Btw, this feature has been requested somewhere in 2008, but by someone
else.

Kind regards,
--Toni++



More information about the nginx mailing list