[Plugin: Geo Redirect] Incorrect (or empty) visitor IP address (REMOTE_ADDR) on certain servers
-
Excellent plugin, exactly what several of our clients were looking for, and it works almost perfectly, except on our live servers.
As it turns out, sometimes a server doesn’t return the visitor’s IP in $_SERVER[‘REMOTE_ADDR’]. Also sometimes it may return a list. It may be behind a proxy, or in a live cluster or some such, and use different $_SERVER variables for the visitor’s IP.
In line 32 of your geo-redirect.php you have;
$this->ip = $_SERVER['REMOTE_ADDR'];
On our live servers, this will fail. Our senior developers have come against this before, and have provided a solution. If we simply replace your code above with this little bit of code below, your plugin works perfectly, even on these more complex server setups;
$ip=$_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { // check ip from share internet $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { // to check ip is pass from proxy $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } $ips = explode(",", $ip); $this->ip=$ips[0];
Any chance you can incorporate this or similar into your next release?
Many thanks!
- The topic ‘[Plugin: Geo Redirect] Incorrect (or empty) visitor IP address (REMOTE_ADDR) on certain servers’ is closed to new replies.