Welcome! Log In Create A New Profile

Advanced

Re: Choose upstream based in a cookie

February 17, 2011 10:23AM
I don't know if that will work (see http://wiki.nginx.org/IfIsEvil)

This will almost certainly work:

[code]
location / {
set_by_lua $backend_ip '
if ngx.var.cookie_memberid ~= "" and ngx.var.cookie_memberid ~= nil then
return "10.10.10.10"
elseif ngx.var.cookie_clientid ~= "" and ngx.var.cookie_clientid ~= nil then
return "10.10.10.15"
else
return "10.10.10.20"
end
';
proxy_pass http://$backend_ip;
}
[/code]

Needs 3rd party lua module.

I only just discovered it myself and starting to learn lua. Seems worth it as it opens up a lot of possibilities without getting into the if is evil issues.
Subject Author Posted

Choose upstream based in a cookie

nfn January 30, 2011 06:14AM

Re: Choose upstream based in a cookie

nfn February 16, 2011 06:10PM

Re: Choose upstream based in a cookie

Dayo February 17, 2011 10:23AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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