Remote_addr not set using x-real-ip

Hi All,

I would just like to check what mistake i did on implementing real-ip
module.
Im using nginx 1.6.2 with real_ip_module enabled:

nginx -V
nginx version: nginx/1.6.2
TLS SNI support enabled
configure arguments: --with-cc-opt=’-g -O2 -fstack-protector
–param=ssp-buffer-size=4 -Wformat -Wformat-security
-Werror=format-security -D_FORTIFY_SOURCE=2’
–with-ld-opt=’-Wl,-Bsymbolic-functions -Wl,-z,relro’
–prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf
–http-log-path=/var/log/nginx/access.log
–error-log-path=/var/log/nginx/error.log
–lock-path=/var/lock/nginx.lock
–pid-path=/run/nginx.pid
–http-client-body-temp-path=/var/lib/nginx/body
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi
–http-proxy-temp-path=/var/lib/nginx/proxy
–http-scgi-temp-path=/var/lib/nginx/scgi
–http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit
–with-ipv6 --with-http_ssl_module --with-http_stub_status_module*
–with-http_realip_module*

i have the following entry on nginx.conf

real_ip_header     X-Forwarded-For;
set_real_ip_from   0.0.0.0/0;
real_ip_recursive  on;

and i added the following to format my logs:

log_format custom_logs '"$geoip_country_code" - “$http_x_forwarded_for”

“$remote_addr” -

in which i get this results:

“-” - “172.16.8.39, 102.103.104.105” - “172.16.8.39” -
“-” - “172.16.23.72, 203.204.205.206” - “172.16.23.72”
“-” - “172.16.163.36, 13.14.15.16” - “172.16.163.36”

the first column does not match any country code on the geoip database
since it is detected as the private IP ( in which this country’s ISP
seems
to have proxy sending the private IP )

if using real_ip modules i should be seeing the source IP on
$remote_addr
in the logs, is that correct? please advise if anyone has encountered
the
same issue. thank you in advanced.

Regards,
Ron

On Mon, Jan 26, 2015 at 09:29:17PM +0800, ron ramos wrote:

Hi there,

I would just like to check what mistake i did on implementing real-ip
module.

real_ip_recursive  on;

That says “tell me the last untrusted address from the list”.

http://nginx.org/r/real_ip_recursive

set_real_ip_from   0.0.0.0/0;

But that says “no address on the list is untrusted”.

So nginx will do something else – probably tell you the first address
from the list. It’s no wronger than anything else, given what you have
configured it to do.

Either turn off recursive, or configure your trusted addresses
correctly.

f

Francis D. [email protected]