PHP implementation detects whether the client uses a proxy server and its anonymous level _php tips

Source: Internet
Author: User
Tags anonymous php example

To determine whether a 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, the client uses a proxy server.

Anonymous levels can be judged by reference to the table below.

Give an example of an application, you can put up a proxy test effect: http://ip.mixsec.org/

First, do not use 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 Server 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 will still be able to forward your information to your Access object, not to hide the real identity.

Third, the use of ordinary anonymous proxy server situation: Anonymous proxies

REMOTE_ADDR = Proxy Server IP
Http_via = Proxy Server 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 Server IP (supplemental: This field is populated by a proxy server, sometimes populating gateway information, etc.)
Http_x_forwarded_for = Random IP
Told the Access object that you used the proxy server, but fabricated a fake random IP instead of your real IP to deceive it.

V. Using a high anonymous proxy server: Gao anonymity proxies

REMOTE_ADDR = Proxy Server IP
Http_via = no value or no display
Http_x_forwarded_for = no value or no display
Completely replaces all your information with the proxy server's information, as if you were using that proxy server directly to access the object.

In addition, some other reference information can be summed up by proxy judges and used in practice.

Finally write a php example, for your reference only:

Copy Code code as follows:

if (!empty ($_server[' Http_via '))//using the agent
{
if (!isset ($_server[' http_x_forwarded_for '))
{
Anonymous proxies Common 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 agent or High anonymous agent
{
Real IP address is $_server[' REMOTE_ADDR ']
}

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.