Welcome! Log In Create A New Profile

Advanced

Re: Altering HTTP Headers

Nick Pearson
August 13, 2009 07:25PM
I've not tried this, but I'm guessing it might work. This assumes
your cookie's name is "something" and has a value of at least one
character in length (hence the ".+" regex).

location / {
if ($cookie_something ~* ".+") {
add_header Cookie "$cookie_something your_suffix_here";
}
}

If you need the suffix to come just after the cookie's original value
(with no spaces in between) you may be able to use the variable format
${cookie_comething} instead of just $cookie_something. This is
another thing I haven't tried myself, but I wouldn't be surprised if
it worked.

Hope that helps, or at least gets you pointed in the right direction.

Nick


On Thu, Aug 13, 2009 at 6:02 PM, Ian Shafer<ian@1321.org> wrote:
> Hello All,
>
> I've migrated from Apache 2 to nginx. Everything is great, except I cannot
> figure out how to alter a n HTTP header. Here's what's happening. I'm using
> nginx as a reverse proxy. The upstream server sets a cookie using the
> Set-Cookie HTTP header. I want to append something to the end of that header
> before it gets to the client.
>
> So, upstream server sends
>
> Set-Cookie: Name=Value
>
> I want it to look like this
>
> Set-Cookie: Name=ValueAppendedContent
>
> How can I do this in nginx? In Apache, here's what I did:
>
> Header edit Set-Cookie $ 'AppendedContent'
>
> Maybe I should mention that I'm doing this because I want to specify the
> cookie domain. (I would do this in my upstream server, but it is
> difficult/not possible.)
>
> Thanks for any tips!
>
> Ian
>
Subject Author Posted

Altering HTTP Headers

Ian Shafer August 13, 2009 07:02PM

Re: Altering HTTP Headers

Nick Pearson August 13, 2009 07:27PM

Re: Altering HTTP Headers

Marcus Clyne August 13, 2009 08:10PM

Re: Altering HTTP Headers

Ian Shafer August 14, 2009 01:08AM

Re: Altering HTTP Headers

Nick Pearson August 14, 2009 09:15AM

Re: Altering HTTP Headers

Ian Shafer August 14, 2009 12:12PM

Re: Altering HTTP Headers

Ian Shafer August 15, 2009 12:12PM

Re: Altering HTTP Headers

Nick Pearson August 13, 2009 07:25PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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