nginx behind load balancer

Maxim Dounin mdounin at mdounin.ru
Fri Nov 25 17:14:40 UTC 2011


Hello!

On Fri, Nov 25, 2011 at 09:54:14AM -0500, Rami Essaid wrote:

> Hi Maxim,
> 
> We implemented to module and still had some trouble.  A lot of the
> connections would return " 503 Service Temporarily Unavailable".  Our
> configuration works fine without the load balancer but then gives these 503
> errors behind the load balancer.

nginx itself will only return 503 if it hits either limit_conn or 
limit_req.

If you see this returned by nginx, and it only happens with load 
balancer, this may indicate you've not configured realip module 
properly (or your load balancer doesn't provide appropriate 
headers) and you are hitting per-ip limits configured due to all 
requests appear to be from load balancer.

Check if client's ip logged is really client's one, not an ip of 
your load balancer.

> Looking into the error logs I notice a lot of these errors both with and
> without the load balancer "connect() failed (111: Connection refused) while
> connecting to upstream".  Could this be the reason that we are having
> issues?

Unlikely, but It's a good idea to track and fix this in any case.

Maxim Dounin

> 
> Thanks!
> Rami
> 
> 
> On Mon, Nov 21, 2011 at 7:46 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> 
> > Hello!
> >
> > On Mon, Nov 21, 2011 at 07:40:49AM -0500, Rami Essaid wrote:
> >
> > > Thanks Maxim,
> > >
> > > This looks like exactly what we need.  In your experience does this
> > resolve
> > > most issues behind a load balancer?
> >
> > Yes.
> >
> > Maxim Dounin
> >
> > > On Mon, Nov 21, 2011 at 7:38 AM, Maxim Dounin <mdounin at mdounin.ru>
> > wrote:
> > >
> > > > Hello!
> > > >
> > > > On Mon, Nov 21, 2011 at 07:25:39AM -0500, Rami Essaid wrote:
> > > >
> > > > > Hi Guys,
> > > > >
> > > > > This weekend for scalability we tried putting our nginx servers
> > behind
> > > > > amazon's elastic load balancers and came across a road block: it
> > does not
> > > > > transparently pass the user IP and header information to nginx. This
> > > > caused
> > > > > issues with several pieces of nginx we use including the IP allow /
> > deny
> > > > > rules, the limit_req module, and the limit_con module.  Has anyone
> > > > > successfully put nginx behind a load balancer?  Any ideas on how to
> > make
> > > > > this work?
> > > >
> > > > http://wiki.nginx.org/HttpRealIpModule
> > > >
> > > > Maxim Dounin
> > > >
> > > > _______________________________________________
> > > > nginx mailing list
> > > > nginx at nginx.org
> > > > http://mailman.nginx.org/mailman/listinfo/nginx
> > > >
> >
> > > _______________________________________________
> > > nginx mailing list
> > > nginx at nginx.org
> > > http://mailman.nginx.org/mailman/listinfo/nginx
> >
> > _______________________________________________
> > nginx mailing list
> > nginx at nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
> >

> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list