Cloudflare can break geolocation
-
We’re using LogicHop and geolocation on WPEngine. Recently we noticed that the geolocation functionality was broken. On investigating, we tracked the issue down to the get_client_ip() method in LogicHop’s core.php file.
Specifically, this block of code:
if (array_key_exists('HTTP_CF_CONNECTING_IP', $_SERVER) && !empty($_SERVER['HTTP_CF_CONNECTING_IP'])) { $client_ip = $_SERVER['HTTP_CF_CONNECTING_IP']; }
In our WPEngine environment, HTTP_CF_CONNECTING_IP does not contain a single IP address, but sometimes two or three, separated by commas,. e.g.. (this is just an example):
$_SERVER['HTTP_CF_CONNECTING_IP'] => '10.199.1.1,10.199.1.2'
When this happens, geolocation functionality breaks completely. The only way we’ve been able to restore it is by editing core.php and removing the block of code above, allowing LogicHop to fall back to another server variable that has the correct (single) IP address.
This is probably more of a Cloudflare issue than a LogicHop issue, but wanted to make you aware that it might be possible for the server variable value to contain multiple IP addresses so you could check for and parse out the first address, if this is the case.
- The topic ‘Cloudflare can break geolocation’ is closed to new replies.