I want to integrate a good proxy detector script on my site. Therefore, on searching I got this code.
$proxy_headers = array(
'HTTP_VIA',
'HTTP_X_FORWARDED_FOR',
'HTTP_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_FORWARDED',
'HTTP_CLIENT_IP',
'HTTP_FORWARDED_FOR_IP',
'VIA',
'X_FORWARDED_FOR',
'FORWARDED_FOR',
'X_FORWARDED',
'FORWARDED',
'CLIENT_IP',
'FORWARDED_FOR_IP',
'HTTP_PROXY_CONNECTION'
);
foreach($proxy_headers as $x){
if (isset($_SERVER[$x])) die("You are using a proxy!");
}
Then I tried accessing my localhost website through ngrok and it blocked me from viewing it returning "You are using a proxy!". I tried with hidemyass and one another proxy detector and I got the same result. This is what I wanted in case of hidemyass type proxy sites. Now my question is that is ngrok also using a proxy server due to which it blocked me from access? And I read someone's comment that HTTP_X_FORWARDED_FOR
returns false positive for his internet direct connection. I tried to remove this and wooo, no more detecting proxies on hidemyass or other. Site is accessible via proxies. So, I guess its important. So, my second question is that does HTTP_X_FORWARDED_FOR
really returns false positive? Or is it because ngrok is also using proxies that I could not access my site through even I was on my direct connection? Is it completely okay to use HTTP_X_FORWARDED_FOR
or not? Any prose or cons you see in this script please tell me.