PHP checks whether the client uses the proxy server and its anonymous level. php proxy server _ PHP Tutorial

Source: Internet
Author: User
Tags php example
PHP checks whether the client uses the proxy server and its anonymous level. PHP checks whether the client uses the proxy server and its anonymous level. The php proxy server must determine whether the client uses the proxy server, you can use PHP to check whether the client uses the proxy server and its anonymous level from the environment variable message sent by the client. The php proxy server

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

Specifically, it refers to the HTTP_VIA field. if this field is set, the client uses the proxy server.

The anonymous level can be determined by referring to the following table.

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

I. no proxy server is used:

REMOTE_ADDR = your IP address
HTTP_VIA = no value or no Display
HTTP_X_FORWARDED_FOR = no value or no Display

II. Transparent Proxy Server: Transparent Proxies

REMOTE_ADDR = proxy server IP address
HTTP_VIA = proxy server IP address (Supplement: This field is filled by the proxy server, and sometimes the Gateway Information is filled)
HTTP_X_FORWARDED_FOR = your real IP address
This type of proxy server still forwards your information to your access object, which cannot hide your real identity.

III. normal Anonymous proxy server: Anonymous Proxies

REMOTE_ADDR = proxy server IP address
HTTP_VIA = proxy server IP address (Supplement: This field is filled by the proxy server, and sometimes the Gateway Information is filled)
HTTP_X_FORWARDED_FOR = proxy server IP address
Your real IP address is hidden, but you are disclosed to the access object that you use the proxy server to access them.

IV. destorting Proxies

REMOTE_ADDR = proxy server IP address
HTTP_VIA = proxy server IP address (Supplement: This field is filled by the proxy server, and sometimes the Gateway Information is filled)
HTTP_X_FORWARDED_FOR = random IP address
It tells the access object that you used the proxy server, but fabricated a false random IP address instead of your real IP address to cheat it.

5. High Anonymity Proxies

REMOTE_ADDR = proxy server IP address
HTTP_VIA = no value or no Display
HTTP_X_FORWARDED_FOR = no value or no Display
The proxy server information replaces all your information, just as you directly access the object using the proxy server.

In addition, you can use proxy judges to complete other judgment information for reference, and use it again in practice.

Finally, write a php example for your reference only:

The code is as follows:


If (! Empty ($ _ SERVER ['http _ VIA ']) // The agent is used.
{
If (! Isset ($ _ SERVER ['http _ X_FORWARDED_FOR '])
{
// Anonymous Proxies normal Anonymous proxy server
// The proxy IP address is $ _ SERVER ['remote _ ADDR ']
}
Else
{
// Transparent Proxies Transparent proxy server
// The proxy IP address is $ _ SERVER ['remote _ ADDR ']
// The real IP address is $ _ SERVER ['http _ X_FORWARDED_FOR ']
}
}
Else // no proxy or highly anonymous proxy
{
// The real IP address is $ _ SERVER ['remote _ ADDR ']
}

Token to determine whether the client uses the proxy server, you can send an environment variable message from the client...

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.