Issue with upstream hash

Wuvist nginx-forum at nginx.us
Mon Jun 14 17:18:08 MSD 2010


Hi, I'm new to Nginx. Really like it.

I was trying to use it as reverse proxy, with following config:
http {
    upstream mobile{
        hash $arg_userid
        server 192.168.0.180;
        server 192.168.0.2:80;
        server 192.168.0.3:80;
    }

    server {
        listen 80;
        listen 8080;
        server_name mobile.test.com;

         location / {
            proxy_pass  http://mobile;
            proxy_redirect     off;
            proxy_set_header   Host             $host;
        }
    }
}
====================
The idea is to load balance the request according to "userid" parameter in querystring.

It works when I visit: http://mobile.test.com:8080/?userid=XXX, but not http://mobile.test.com/?userid=XXX

The request to 8080 port could be hash to different server correctly, but the requests to 80 port just sent to random server.

I'm really puzzled. 

Any feedback are welcome. Thanks.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,97972,97972#msg-97972




More information about the nginx mailing list