PHP: Determine whether the client uses a proxy server and its anonymity level_PHP tutorial

WBOY
Release: 2016-07-13 10:31:32
Original
713 people have browsed it

To determine whether the client uses a proxy server, you can judge from the environment variable information sent by the client.

Specifically, look at the HTTP_VIA field. If this field is set, it means that the client uses a proxy server.

The level of anonymity can be determined by referring to the table below.

Given an application example, you can hang up a proxy and try the effect: http://ip.mixsec.org/

1. When not using a proxy server:
REMOTE_ADDR = Your IP
HTTP_VIA = No value or not displayed
HTTP_X_FORWARDED_FOR = No value or not displayed


2. The use of transparent proxy servers: Transparent Proxies

REMOTE_ADDR = Proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = Your real IP
This type of proxy server is still Forwarding your information to the person you visit cannot achieve the purpose of hiding your true identity.

3. The situation of using ordinary anonymous proxy servers: Anonymous Proxies
REMOTE_ADDR = Proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = Proxy server IP
Hide your real IP, but reveal to the visitors that you use a proxy server to access them.

4. The use of deceptive proxy servers: Distorting Proxies
REMOTE_ADDR = Proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = Random IP
Tell the visitor that you are using a proxy server, but make up a fake random IP to replace your real IP to deceive it.

5. Situation of using high anonymity proxy server: High Anonymity Proxies
REMOTE_ADDR = Proxy server IP
HTTP_VIA = No value or no display
HTTP_X_FORWARDED_FOR = No value or no display
Use proxy completely The server's information replaces all your information, as if you were using that proxy server to directly access the object.


In addition, some other reference judgment information can be summarized through proxy judges and used in practice.

Finally write a php example for your reference only:

<span if</span>(!<span empty</span>(<span $_SERVER</span>['HTTP_VIA']))    <span //</span><span 使用了代理</span>
<span {
    </span><span if</span>(!<span isset</span>(<span $_SERVER</span>['HTTP_X_FORWARDED_FOR'<span ]))
    {
        </span><span //</span><span Anonymous Proxies    普通匿名代理服务器

        //代理IP地址为 $_SERVER['REMOTE_ADDR']</span>
<span 
   }
   </span><span else</span><span 
   {
        </span><span //</span><span Transparent Proxies 透明代理服务器
        //代理IP地址为 $_SERVER['REMOTE_ADDR']
        //真实ip地址为 $_SERVER['HTTP_X_FORWARDED_FOR']</span>
<span    }
}
</span><span else</span>    <span //</span><span 没有代理或者是高匿名代理</span>
<span {
    </span><span //</span><span 真实ip地址为 $_SERVER['REMOTE_ADDR']</span>
}
Copy after login

Reprinted from: http://blog.csdn.net/alexdream/article/details/6120204

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/763355.htmlTechArticleTo determine whether the client uses a proxy server, you can judge from the environment variable information sent by the client. Specifically, it looks at the HTTP_VIA field. If this field is set, it says...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!