Tag Archives: http_x_forwarded_for

Nginx: set REMOTE_ADDR to HTTP_X_FORWARDED_FOR

I use apache2 as frontend proxy (on the gateway) and nginx as backend (on the internal host).
Apache sends its IP as REMOTE_ADDR and IP of client as HTTP_X_FORWARDER_FOR.
Statistics of unique IPs in my blog was destructed, but I found solution.
In the nginx settings set option AFTER include:
1
location ~ .php$ {
1
    
1
fastcgi_pass 127.0.0.1:9000;
1
    

1
include fastcgi.conf;
1
    

1
fastcgi_param REMOTE_ADDR $http_x_forwarded_for;
1
}