13 messages in ru.sysoev.nginxRe: nginx not setting REMOTE_ADDR pro...
FromSent OnAttachments
Mohammad KolahdouzanFeb 23, 2009 4:01 pm 
mikeFeb 23, 2009 4:23 pm 
Mohammad KolahdouzanMar 4, 2009 6:52 pm 
Abhishek SinghMar 4, 2009 7:05 pm 
Mohammad KolahdouzanMar 4, 2009 8:29 pm 
Abhishek SinghMar 4, 2009 8:38 pm 
Mohammad KolahdouzanMar 5, 2009 7:24 am 
Igor SysoevMar 5, 2009 7:28 am 
Mohammad KolahdouzanMar 5, 2009 9:17 am 
Igor SysoevMar 5, 2009 11:53 am 
Mohammad KolahdouzanMar 11, 2009 10:37 pm 
Mohammad KolahdouzanMar 11, 2009 10:50 pm 
Mohammad KolahdouzanApr 19, 2009 9:43 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: nginx not setting REMOTE_ADDR properly?Actions...
From:Mohammad Kolahdouzan (moha@yahoo.com)
Date:Mar 5, 2009 9:17:48 am
List:ru.sysoev.nginx

It is working perfectly fine now, thanks.

I was originally using $http_remote_addr since I noticed in the source code that
any variable that starts with "http_" will have nginx retireve the variable from
the headers_in, and also noticed that remote_addr is reserved to hold the IP of
the actual connection which in my case, would naturally return the IP of the
load balancer. But it didn't work when the "underscores_in_headers on" flag was
not specified in the config file.

So out of curiosity, if there is any variable in the header that is already
reserved by nginx for another purpose, e.g., remote_port, we should use this
underscores_in_headers to retrieve it, or did it work simply because the header
had a underscore in it (i.e., REMOTE_ADDR) and the headers normally don't have
underscores and the lack of the flag was causing Nginx to consider REMOTE_ADDR
to be an invaluid header and ignore it?

Thanks for the help, -M

________________________________ From: Igor Sysoev <is@rambler-co.ru> To: ngi@sysoev.ru Sent: Thursday, March 5, 2009 7:29:13 AM Subject: Re: nginx not setting REMOTE_ADDR properly?

On Wed, Mar 04, 2009 at 06:52:50PM -0800, Mohammad Kolahdouzan wrote:

My nginx is getting requests through a (NetScaler) load balancer, and
$remote_addr is returning the load balancer's IP and not the real user's IP
(which the load balancer sets as REMOTE_ADDR in the header). Any other attribute
I should use to get the real user's IP?

You should use $http_remote_addr and set:

server { underscores_in_headers on;