rvagg/mod_geoip2_xff — pull request #1 by KevinGaudin (2012-07-05 10:15:02+00:00)
Title: use the remote_ip if no public ip is found in the proxy headers

Hi,

As we started to discuss on your bog post, I modified the fallback rule to use the remote_ip if no public ip is found in the proxy headers. Geolocation would not have worked anyway and we might still find some useful location in the remote_ip.

So the logic is:
- If a proxied IPs list is provided (X-Forwarded-For or others), use the left-most non-private IP in the list (your patch)
- if all proxied IPs are private, then return the request client host IP (my addition)

The result can't be worse than "no geolocation" and in some cases it will enhance the detection, especially for the test case that was failing for me:
- client (private IP in XFF) => enterprise proxy (public IP in REMOTE_HOST) => web server

And we continue to cover the other cases like:
- client (public IP in XFF) => CDN or RP (public IP in REMOTE_HOST) => Web server
- client (private IP in XFF) => Enterprise Proxy (public IP in XFF) => CDN or RP (public IP REMOTE_HOST) => Web Server
- client (private IP in XFF) => Enterprise Proxy (public IP in XFF) => CDN (public IP in XFF) => RP (public IP REMOTE_HOST) => Web Server
- client (public IP in REMOTE_HOST) => Web Server

Kevin