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...