Getting Real IP For nginx & Blocking IP on HAProxy

Getting Real IP For nginx & Blocking IP on HAProxy
· ·

In Tech in Asia, we are using HAProxy as our load balancer and the request is passed on to either of the two web servers running on nginx to process the request. Because the request always comes from the load balancer, under the access logs, the IP will always be the load balancer IP.

Our HAProxy uses the setting option forwardfor which will forward the original client’s IP under the “X-Forwarded-For” header.