I noticed that the GeoIP library was not being able to recognize the IP address of any users in my website, when reviewing the code of the GeoIP Library I noticed that the IP address of my website users is not available in any of the header variables that the getIP method is looking.
This method looks for the User IP in the following headers: HTTP_X_FORWARDED_FOR, HTTP_X_REAL_IP, HTTP_CLIENT_IP
I use Cloudflare with my website, to proxy requests to my server and for some reason the IP Address of my users is not available in any of the above headers. However, Cloudflare adds the Header HTTP_CF_CONNECTING_IP with the IP address of the user.
So I changed the getIp method to include this Header and GeoIp is working as expected. I was wondering if there is some way to include this change as an override to the library so that I can keep updating Regular Labs GeoIp Extension without losing this change every time I update? Can anyone help me with that?
I will also try to change settings in my cloudflare account to include one of the originally checked headers.
Sorry for reopening this post, I did notice another with GeoIP and users with IPv6 addresses. The GeoIp library has a function to validate IP addresses, this function is flagging IPv6 Addresses as invalid, even though the MaxMind database supports IPv6 addresses.
I edited the isValidIP function to also accept IPv6 addresses, you can find my edit below:
Since then, it seems to be working with IPv6 addresses. Could you please look into this issue and maybe add a similar change to the next release of the GeoIp plugin ?