Welcome! Log In Create A New Profile

Advanced

Re: Nginx multiple upstream map conditions

August 31, 2016 01:42PM
Valentin V. Bartenev Wrote:
-------------------------------------------------------
> On Tuesday 30 August 2016 14:25:28 c0nw0nk wrote:
> > So this is a fun one.
> >
> > As allot of people probably already know you can't use "IF" on
> upstream
> > values since if conditions are executed before any "$upstream_"
> conditions.
> >
> > But with a map directive it might just be possible to combine 2
> upstream
> > maps together and have a output based on the conditions matched.
> >
> > Here is what I am trying to achieve.
> >
> > If the upstream returns with a logged_in value of 1 then we forward
> and pass
> > the Set-Cookie header to the client "add_header".
> > Else the "add_header Set-Cookie" should be empty.
> >
> > ##logged in value 0 = guest
> > ##logged in value 1 = has an account
> > map $upstream_cookie_logged_in $upstream_logged_in_value {
> > default $upstream_cookie_logged_in;
> > }
> >
> > map $upstream_http_set_cookie $upstream_md5_value {
> > default $upstream_http_set_cookie;
> > }
> >
> >
> > add_header Set-Cookie $upstream_md5_value; ##Only want to send the
> MD5
> > cookie when the logged in value is 1
> >
> >
> > fastcgi_hide_header Set-Cookie; ##Removed the set-cookie and to be
> added in
> > only when conditions are met. "add_header"
> >
> >
> > Thanks in advance to anyone who can help me out :D
> >
> [..]
>
> map $upstream_cookie_logged_in $upstream_md5_value {
> 1 $upstream_http_set_cookie;
> }
>
> add_header Set-Cookie $upstream_md5_value;
>
> wbr, Valentin V. Bartenev
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


Thanks works a treat is it possible or allowed to do the following in a nginx upstream map ? and if so how i can't figure it out.


I cache with the following key.
fastcgi_cache_key "$session_id_value$scheme$host$request_uri$request_method";


if the upstream_cookie_logged_in value is not equal to 1 how can I set $session_id_value ''; make empty

http://www.networkflare.com/
Subject Author Posted

Nginx multiple upstream map conditions

c0nw0nk August 30, 2016 02:25PM

Re: Nginx multiple upstream map conditions

Valentin V. Bartenev August 31, 2016 07:06AM

Re: Nginx multiple upstream map conditions

c0nw0nk August 31, 2016 01:30PM

Re: Nginx multiple upstream map conditions

c0nw0nk August 31, 2016 01:42PM

Re: Nginx multiple upstream map conditions

Francis Daly August 31, 2016 05:58PM

Re: Nginx multiple upstream map conditions

c0nw0nk August 31, 2016 06:44PM

Re: Nginx multiple upstream map conditions

c0nw0nk August 31, 2016 09:17PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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