Fwd: How can i have multiple nginx plus servers route to the same app servers with sticky sessions o

I have multiple nginx instances behind an AWS elastic load balancer. In
the
nginx config files, I am using ip_hash to force sticky sessions when
connecting upstream. Is there a way to sync the route tables between the
multiple nginx servers, so that no matter which nginx server handles the
request, the traffic is sent to the same backend application server.

When I first set this scenario up, I had no problems. But after heavy
testing with multiple clients from different parts of the world, I was
able
to verify that the multiple nginx servers were not choosing the same
backend application servers to route to.

I attached a drawing that explains the architecture visually.

Matt

Hello!

On Thu, Jun 18, 2015 at 10:13:18AM -0700, Matt wrote:

I have multiple nginx instances behind an AWS elastic load balancer. In the
nginx config files, I am using ip_hash to force sticky sessions when
connecting upstream. Is there a way to sync the route tables between the
multiple nginx servers, so that no matter which nginx server handles the
request, the traffic is sent to the same backend application server.

When I first set this scenario up, I had no problems. But after heavy
testing with multiple clients from different parts of the world, I was able
to verify that the multiple nginx servers were not choosing the same
backend application servers to route to.

First of all, as you use AWS, make sure all nginx instances
properly see client addresses (and not addresses of Amazon ELB).
If nginx sees ELB addresses instead, you have to configure the
realip module appropriately, see
Module ngx_http_realip_module.

An additional problem which may hurt your case is upstream server
errors. See this message for a detailed explanation:

http://mailman.nginx.org/pipermail/nginx/2015-May/047590.html


Maxim D.
http://nginx.org/