X-Forwarded-For can be used to identify the outgoing IP address of a client connecting to the web server through an HTTP proxy or load balancer.
The general format of this field
X-Forwarded-For: client, proxy1, proxy2
In the above example, you can see that the request is passed through proxy1 and proxy2.
In your case, you have to parse this comma and read the first value, which is the client IP address.
A warning. It's easy to fake the X-Forwarded-For field so you can get the wrong information.
Please see https://en.wikipedia.org/wiki/X-Forwarded-For to find out more about this.
source share