Switching backends based on a cookie
    saltyflorida 
    nginx-forum at nginx.us
       
    Fri Jan 29 02:43:22 MSK 2010
    
    
  
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
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,46979,46979#msg-46979
    
    
More information about the nginx
mailing list