ip_hash and multiple clients on the same host

bobfang_sqp nginx-forum at forum.nginx.org
Fri Oct 30 15:29:39 UTC 2020


Hi I am using nginx as a load balacer and I require sticky session (same
client always go to the same server), for this purpose I use this following
setup:


    upstream backend {
       ip_hash;
       server host1:8000;
       server host2:8000;
    }

The `ip_hash` directive is what I learned from online docs, but I am just
wondering does this mean that all the requests from the same host will be
routed to the same upstream server? Since I may have multiple clients
running on the same host, I want to still distribute these requests to
different upstream servers but if I am using ip_hash does that imply if two
clients are on the same host they will be routed to the same server because
they share the same ip? There seems to be some more advanced configs to
achieve sticky session but seems that would require nginx plus which I dont
have...  My intention is that even if two clients come from same host they
should probably go to different server, but after they are assigned an
upstream server they should stick to that one. Thanks!

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



More information about the nginx mailing list