[Mongrel] Nginx, Mongrel, Proxy and REMOTE_ADDR

Aleksandar Lazic al-mongrelusers at none.at
Wed Nov 1 13:55:42 EST 2006


On Mit 01.11.2006 10:26, Joey Geiger wrote:
>I'm using a cluster of mongrels behind an apache 1.3 proxy pass. I've
>been passing the request to pen, which in turn balances the cluster of
>mongrels. Now, I'd like to be able to use a different server to send
>the static files created by the rails application, so I tried to
>replace pen with nginx. Everything seems to work fine except the
>environment variable REMOTE_ADDR.

I think this isn't a mongrel issue.

>When I do a <%= request.env["REMOTE_ADDR"] %> with pen balancing, it
>sends in the proper (and expected) 192.168.1.21.
>
>When nginx is the balancer, the output becomes: 192.168.1.21, 127.0.0.1.
>
>the nginx proxy information I have set is:
>
>proxy_redirect           off;
>proxy_set_header         Host $host;
>proxy_set_header         X-Real-IP $remote_addr;
>proxy_set_header         X-Forwarded-For $proxy_add_x_forwarded_for;

What do you get when you add this line:

proxy_set_header REMOTE_ADDR        $remote_addr;

More about the proxy module can you find here:

http://wiki.codemongers.com/NginxHttpProxyModule

>Just wondering if anyone else has run into this problem, and it's
>possible solution.

How about to ask this on nginx list, I think it *could* be the better
list ;-)

Regards

Aleks


More information about the Mongrel-users mailing list