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.


The Upstream module does this. In http section:

upstream app {

  server backend1;
  server backend2;

In your location:

location / {
  proxy_pass http://app;

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...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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