Issue with IP Headers for Geo IP use

Search
Other Bug Reports questions
Forum

Issue with IP Headers for Geo IP use

Luiz Felipe  Tavares's Avatar Luiz Felipe Tavares
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.
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version from:
regularlabs.com/development-releases

Alternatively you can also switch on the "Restore Original Visitor IP" option at Cloudflare.
Please post a rating at the Joomla! Extensions Directory
Luiz Felipe  Tavares's Avatar Luiz Felipe Tavares
Thank you for the quick assistance!

The development version works as expected.
Peter van Westen's Avatar Peter van Westen ADMIN
Ok, great 🙂
The fix will be included in the next release.
Please post a rating at the Joomla! Extensions Directory
Luiz Felipe  Tavares's Avatar Luiz Felipe Tavares
Hello,

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:

private function isValidIP(string $string): bool
{
return filter_var($string, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6 | \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE);
}

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 ?

Thank you very much in advance!
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version from:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Luiz Felipe  Tavares's Avatar Luiz Felipe Tavares
Thank you very much for the prompt response.

I tested the development version and it is working fine.
Peter van Westen's Avatar Peter van Westen ADMIN
Ok, great 🙂
The fix will be included in the next release.
Please post a rating at the Joomla! Extensions Directory
You can only post on this forum if you log in