proxy_pass to backend (varnish): delivered ip?

revirii nginx-forum at nginx.us
Wed Jan 30 15:33:25 UTC 2013


Hey,
maybe the solution is really simple, but i can't find it.

nginx (1.2.1) handles ssl and proxies the traffic to the backend (varnish,
which also handles http):

location / {
        proxy_set_header  Host   $host;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:80;
}

The requests are sent to varnish, in the varnish logs i see them, they look
like (shortened):

127.0.0.1 - - [30/Jan/2013:16:06:54 +0100] .........

So varnish receives 127.0.0.1 from nginx, but i want varnish to receive the
external ip.

For testing reasons i switched the ip to the lan ip (which varnish also
listens to):

location / {
        proxy_set_header  Host   $host;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://192.168.0.1:80;
}

And now the requests in varnish log look like:

192.168.0.1 - - [30/Jan/2013:16:16:25 +0100] .........

Well, where's the error? How can it be done that varnish receives the
external ip (smth. like 84.156.23.145) from nginx? I suppose it's quite
simple but i can't see it... :-/

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,235737,235737#msg-235737



More information about the nginx mailing list