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

vi /etc/nginx/nginx.conf

Find

Advertisement

http {

Inside http section, add

set_real_ip_from IP_ADDRESS_OF_PROXY_SERVER_HERE;
real_ip_header X-Forwarded-For;

Example

set_real_ip_from 192.168.122.1;
real_ip_header X-Forwarded-For;

Restart Nginx

nginx -s reload
Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement