PHP: Determining whether a client uses a proxy server and its anonymous level

Source: Internet
Author: User
Tags php example

To determine whether a client uses a proxy server, it can be judged from the environment variable information sent by the client.

Specifically, just look at the Http_via field, if this field is set, the client uses a proxy server.

The anonymous level can be judged by the following table.

Give an example of application, you can hang up the agent trial effect: http://ip.mixsec.org/

One, not using the proxy server situation:
REMOTE_ADDR = Your IP
Http_via = no value or no display
Http_x_forwarded_for = no value or no display


Second, the use of transparent proxy server situation: Transparent Proxies

REMOTE_ADDR = Proxy Server IP
Http_via = proxy IP (supplemental: This field is populated by a proxy server, sometimes populating gateway information, etc.)
Http_x_forwarded_for = Your real IP
This type of proxy server also forwards your information to your Access object, and does not achieve the purpose of hiding the true identity.

Third, the use of ordinary anonymous proxy server situation: Anonymous Proxies
REMOTE_ADDR = Proxy Server IP
Http_via = proxy IP (supplemental: This field is populated by a proxy server, sometimes populating gateway information, etc.)
http_x_forwarded_for = Proxy Server IP
Hides your real IP, but reveals to the Access object that you are using a proxy server to access them.

Iv. use of deceptive proxy servers: distorting Proxies
REMOTE_ADDR = Proxy Server IP
Http_via = proxy IP (supplemental: This field is populated by a proxy server, sometimes populating gateway information, etc.)
Http_x_forwarded_for = Random IP
Tells the Access object that you used a proxy server, but fabricated a bogus random IP to spoof it instead of your real IP.

V. Use of highly anonymous proxy servers: High anonymity Proxies
REMOTE_ADDR = Proxy Server IP
Http_via = no value or no display
Http_x_forwarded_for = no value or no display
Full use of Proxy server information replaces all of your information, as if you were using the proxy server directly to access the object.


In addition, the proxy judges can be used to summarize other reference information, once again in practice.

Finally write a php example, for your reference only:

if(!Empty($_server[' Http_via ']))//using a proxy{    if(!isset($_server[' Http_x_forwarded_for ']))    {        //Anonymous Proxies Normal anonymous proxy server//proxy IP address is $_server[' remote_addr ']   }   Else   {        //Transparent Proxies Transparent proxy server//proxy IP address is $_server[' remote_addr '//Real IP address is $_server[' http_x_forwarded_for ']    }}Else    //no proxy or high anonymous proxy{    //The real IP address is $_server[' remote_addr ']}

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.