Welcome! Log In Create A New Profile

Advanced

Re: Removing a request header in an access phase handler

Maxim Dounin
July 09, 2013 07:16AM
Hello!

On Tue, Jul 09, 2013 at 12:13:37AM +0200, Jan Algermissen wrote:

> Hi Maxim,
>
> thanks, question inline:
>
> On 08.07.2013, at 19:59, Maxim Dounin <mdounin@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?

Quoting myself:

: Removing request headers from a request isn't something
: supported by nginx.

If you are going to remove request headers - first of all, you
should understand that what you are doing is a hack. And asking
me what do I think is a bit pointless - I think it's a hack. :)

--
Maxim Dounin
http://nginx.org/en/donation.html

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

Removing a request header in an access phase handler

Jan Algermissen July 08, 2013 12:46PM

Re: Removing a request header in an access phase handler

Maxim Dounin July 08, 2013 02:00PM

Re: Removing a request header in an access phase handler

Jan Algermissen July 09, 2013 01:40AM

Re: Removing a request header in an access phase handler

Maxim Dounin July 09, 2013 07:16AM

Re: Removing a request header in an access phase handler

David Pesce March 06, 2014 08:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 214
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