Removing a request header in an access phase handler

Jan Algermissen jan.algermissen at nordsc.com
Mon Jul 8 22:13:37 UTC 2013


Hi Maxim,

thanks, question inline:

On 08.07.2013, at 19:59, Maxim Dounin <mdounin at mdounin.ru> wrote:

> Hello!
> 
> On Mon, Jul 08, 2013 at 06:45:33PM +0200, Jan Algermissen wrote:
> 
>> Hi,
>> 
>> I developing a handler for the access phase. In this handler I 
>> intend to remove a certain header.
>> 
>> It seems that this is exceptionally hard to do - the only hint I 
>> have is how it is done in the headers_more module.
>> 
>> However, I wonder, whether there is an easier way, given that it 
>> is not an unusual operation.
> 
> Removing request headers from a request isn't something supported 
> by nginx.
> 
> What is supported is filtering/modification of headers passed to 
> upstream servers with proxy_set_header (fastcgi_param, ...).
> 
> E.g., this is how proxy module provies a way to add 
> X-Forwarded-For header.  It implements the $proxy_add_x_forward_for 
> variable, which is expected to be used in a config like this:
> 
>   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> 
>> If not, I'd greatly benefit from a documentation of the list and 
>> list-part types. Is that available somewhere? Seems hard to 
>> figure out all the bits and pieces that one has to go through to 
>> cleanly remove an element from a list.
> 
> Try looking into src/core/ngx_list.[ch] for a documentation in C.  
> It doesn't really support elements removal though.

Yes, I could provide a list_remove implementation - problem is, I think that the request->headers_in convenience fields point to elements of the .headers list, yes? Given that list elts is an array, re-organizing that array would invalidate the pointers of headers_in.

Right ow, I think that renaming the header in question and setting the headers_in field to null is probably the only option.

What do you think?

Jan



> 
> -- 
> Maxim Dounin
> http://nginx.org/en/donation.html
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list