Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 3 down vote accepted

The Upstream module does this. In http section:

upstream app {

  server backend1;
  server backend2;

In your location:

location / {
  proxy_pass http://app;
share|improve this answer

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

share|improve this answer

Your Answer


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.