Show Real IP Nginx Behind Reverse Proxy
When your Nginx web server is running behind a reverse proxy, you will see IP of the reverse proxy server as visitor IP in web servers access log.
To fix this, edit nginx.conf file
1 |
vi /etc/nginx/nginx.conf |
Find
1 |
http { |
Inside http section, add
1 2 |
set_real_ip_from IP_ADDRESS_OF_PROXY_SERVER_HERE; real_ip_header X-Forwarded-For; |
Example
1 2 |
set_real_ip_from 192.168.122.1; real_ip_header X-Forwarded-For; |
Restart Nginx
1 |
nginx -s reload |