PHP instance sharing determines whether the client uses the proxy server and its anonymous level

Source: Internet
Author: User
Tags php example

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:

Copy codeThe 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 ']
}

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.