I am using nginx as the load balancer and IIS to server asp.net pages. However I am having trouble figuring out how to set sticky session in nginx. Is it possible? Thanks.

link|improve this question

feedback

2 Answers

up vote 3 down vote accepted

The Upstream module does this. In http section:

upstream app {
  ip_hash;

  server backend1;
  server backend2;
}

In your location:

location / {
  proxy_pass http://app;
}
link|improve this answer
feedback

The above answer is correct, to include ip_hash; in your upstream configuration, but I wanted to add, do not fair; or weight or other configurations in upstream as they can conflict with the ip_hashing... If you need sticky sessions based on something other than the IP of the visitor, time to go looking...

http://wiki.nginx.org/NginxHttpUpstreamModule

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.