ip_hash and real_ip_header

Laurence Rowe l at lrowe.co.uk
Tue Jan 26 02:19:56 MSK 2010


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   127.0.0.1;
    real_ip_header     X-Forwarded-For;
...
    upstream backend {
ip_hash;
server 127.0.0.2:5011;
server 127.0.0.2:5012;
    }
...

Should this work?

Laurence



More information about the nginx mailing list