Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

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;
}
share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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