ip_hash and real_ip_header

Marcus Clyne ngx.eugaia at gmail.com
Tue Jan 26 03:46:41 MSK 2010


Laurence Rowe wrote:
> Hi,
> I've got Nginx 0.7.64 running as a loadbalancer / transformation proxy
> behind varnish. I'd like to use ip_hash so users get the benefit of
> session affinity on my app servers. Though I seem to have
> real_ip_header setup correctly ($remote_addr is correct as shown by
> X-Real-IP on my app servers), all the requests end up using only a
> single app server. Here's the relevant parts of my config:
> http {
> ...
>     set_real_ip_from;
>     real_ip_header     X-Forwarded-For;
> ...
>     upstream backend {
> ip_hash;
> server;
> server;
>     }
> ...
> Should this work?
Should do AFAICT.  Have you tried compiling with debug on - information 
about IP addresses is given if you have debug_http set in the config file?

Have you tried round-robin to check that both servers work that way?

btw, if you don't need to have a trace of all the IP addresses of the 
servers, using X-Real-IP as the 'real_ip_header' is marginally quicker 
than X-Forwarded-For.


More information about the nginx mailing list