Welcome! Log In Create A New Profile

Advanced

Re: Selectively implement something like proxy_ignore_headers Set-Cookie?

Jonathan Matthews
March 08, 2013 01:46PM
On 8 March 2013 17:00, Peter Booth <Peter_Booth@s5a.com> wrote:
> Some of the locations use the combination of
>
> proxy_ignore_headers Set-Cookie and proxy_hide_header Set-Cookie to strip
> cookies from cached responses.
>
> Another location needs to allow for session cookies to be created and so it
> has the default nginx behavior of not caching
>
> responses that contain cookies.
>
> Now I need a different hybrid behavior-
>
> if a response contains “Set-Cookie: TLTHID”, then strip it from the
> response, but still cache the response.
>
> If the response contains any other Set-Cookie header then don’t cache the
> response.
>
> Is there a way to achieve this within a single nginx instance?

I don't use nginx as a cache, so I can't speak as for how this will
work with the caching subsystem, but I wonder if something like this
might work:

-----------------------------
map $sent_http_set_cookie $header_to_drop {
default NA;
~TLTHID Set-Cookie;
}

server {
proxy_pass http://upstream.fqdn;
proxy_ignore_headers $header_to_drop;
proxy_hide_header $header_to_drop;
}
-----------------------------

The map might need $upstream_http_set_cookie instead - I don't recall
the difference off the top of my head.

HTH,
Jonathan
--
Jonathan Matthews // Oxford, London, UK
http://www.jpluscplusm.com/contact.html

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

Selectively implement something like proxy_ignore_headers Set-Cookie?

Peter Booth March 08, 2013 12:05PM

Re: Selectively implement something like proxy_ignore_headers Set-Cookie?

Jonathan Matthews March 08, 2013 01:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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