Real IP Address For Nginx BEHIND A REVERSE PROXY or HA Proxy

Firstly you need to configure HAProxy to pass the client IP address, which is quite simply done by adding the “forwardfor” and “http-server-close” options to the backend, ensuring that the real client IP reaches the backend web servers via the X-Forwarded-For header. Here is the configuration I’m using for my HTTP backend:

Server HA Proxy :

example IP :

Configuration haproxy.conf

add line backend http :

option http-server-close

option forwardfor

OR Add line :


option httpclose
option forwardfor


Server Nginx :

Nginx Webserver

You’ll need to configure and compile Nginx with the –with-http_realip_module option.

Cek Module nginx http_realip_module option ..

Nginx -V

Then set the following option in the Nginx configuration:

Configuration nginx.conf

set_real_ip_from; # <- IP HAPROXY

set_real_ip_from; # <- IP HAPROXY

real_ip_header X-Forwarded-For;

   REstart Nginx

Posted on: March 6, 2019, by :  | 2 views