Is it possible to switch backend clusters of servers based on a cookie?
I would like to set a cookie named "env" and do something like this:
if ($http_cookie ~* "env=testing(;|$)") {
proxy_pass http://backend_testing;
}
if ($http_cookie ~* "env=staging(;|$)") {
proxy_pass http://backend_staging;
}
if ($http_cookie ~* "env=production(;|$)") {
proxy_pass http://backend_production;
}
However the "proxy_pass" directive is not allowed inside an "if". Is there another way I can approach this?
Thanks,
Eliot