Obtain real Ip from NGINX which is receiving from external L4 load balancer

When a client use our services, network first go through L4 load balancer of our cloud provider(I don't have much control over this other than customer support).

In our server, traffic first hit the NGINX layer (dockerized) then passing to the backend services.

Nginx is receiving the load balancer's IP. "X-Forwarded-For" also null in the requests.

How can I obtain the real client IP from Nginx side?


Since there is a L4 load balancer, it means that the load balancer creates the TCP connections to your nginx.

The only information available with a TCP connection is the IP address of the other end, which is load balancer in your case.

If you want to receive the actual client IP addresses, you need to use a reverse proxy, which adds the original client IP address as a header to the request to your origin server.