ip_hash and multiple clients on the same host

Sergey A. Osokin osa at freebsd.org.ru
Fri Oct 30 20:46:46 UTC 2020


On Fri, Oct 30, 2020 at 11:29:39AM -0400, bobfang_sqp wrote:
> 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!

Hi,

a couple of options in this case:
- sticky session feature is available as part of commecial subscription with
  NGINX Plus;
- NGINX Sticky module for NGINX OSS is available in GH, here's the link to
  one of the forks, https://github.com/ayty-adrianomartins/nginx-sticky-module-ng

--
Sergey


More information about the nginx mailing list