How to Block Proxy/VPN users Accessing Website

KHR

Elite Member
Jr. VIP
Joined
Dec 9, 2013
Messages
4,700
Reaction score
1,635
Hello,

I want to block visitor that use Proxy/VPN to browse website. I want only real IP users can access the site.

How to do it.? Please suggest the easy & best solution to do it.

Thanks in advance...
 
Just run this function to detect if proxy is used, and if so, you can use whatever analytics code you want or block the user.

Code:
function proxy_detected()
{
  if (
     $_SERVER['HTTP_X_FORWARDED_FOR']
  || $_SERVER['HTTP_X_FORWARDED']
  || $_SERVER['HTTP_FORWARDED_FOR']
  || $_SERVER['HTTP_CLIENT_IP']
  || $_SERVER['HTTP_VIA']
  || in_array($_SERVER['REMOTE_PORT'], array(8080,80,6588,8000,3128,553,554))
  || @fsockopen($_SERVER['REMOTE_ADDR'], 80, $errno, $errstr, 30))
  {
      return true;
  } else {
      return false;
  }
}

echo ( proxy_detected() ) ? "Proxy detected" : "No proxy detected";
 
  • Like
Reactions: KHR
Back
Top