开发者

Detect whether a user is behind a free web proxy?

开发者 https://www.devze.com 2023-01-06 02:00 出处:网络
Please let me know how to detect whether a user is behind a fre开发者_运维技巧e web proxy?You basically need a database of all known web proxies. If you want this because you want to disallow access f

Please let me know how to detect whether a user is behind a fre开发者_运维技巧e web proxy?


You basically need a database of all known web proxies. If you want this because you want to disallow access for users behind a proxy, I would say it's a waste of time. New proxies come up all the time and it's difficult to maintain a database that is up-to-date.


Unless you have an exhaustive list of every free web proxy you cannot (and more are being added every day)

Can you tell us more of what you are trying to do? Maybe we can find another way to help you.


I don't know much about proxy servers, but I was under the impression that you could check the X-FORWARDED-FOR field in the HTTP header.


if( ($_SERVER['HTTP_ACCEPT_ENCODING'] == "") or !isset($_SERVER['HTTP_ACCEPT_ENCODING']) )
{
    // using a proxy
    echo( "<font color=red><b>Using a Proxy</b></font><br>" );
}
else
{
    // not using a proxy
    echo( "<font color=green><b>Not using a Proxy</b></font><br>" );
}

I looked trough the $_SERVER array with and without using a proxy, and I found out that when behind a proxy, $_SERVER['HTTP_ACCEPT_ENCODING'] isn't used, and when not behind a proxy, it is used. I haven't found any proxies that use it yet, and I also haven't found any case of where $_SERVER['HTTP_ACCEPT_ENCODING'] isn't used when not using a proxy.

Just test it yourself, you'll see it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消