The wikipedia description of the HTTP header X-Forwarded-For
is:
X-Forwarded-For: client1, proxy1, proxy2, ...
The nginx documentation for the directive real_ip_header
reads, in part:
This directive sets the name of the header used for transferring the replacement IP address.
In case of X-Forwarded-For, this module uses the last ip in the X-Forwarded-For header for replacement. [Emphasis mine]
These two descriptions seem at odds with one another. In our scenario, the X-Forwarded-For
header is exactly as described -- the client's "real" IP address is the left-most entry. Likewise, the behavior of nginx is to use the right-most value -- which, obviously, is just one of our proxy servers.
My understanding of X-Real-IP
is that it is supposed to be used to determine the actual client IP address -- not the proxy. Am I missing something, or is this a bug in nginx?
And, beyond that, does anyone have any suggestions for how to make the X-Real-IP
header display the left-most value, as indicated by the definition of X-Forwarded-For
?