Home > Backend Development > PHP Tutorial > PHP implementation detects whether the client uses a proxy server and its anonymity level, php proxy server_PHP tutorial

PHP implementation detects whether the client uses a proxy server and its anonymity level, php proxy server_PHP tutorial

WBOY
Release: 2016-07-13 10:10:00
Original
846 people have browsed it

PHP implementation detects whether the client uses a proxy server and its anonymity level, php proxy server

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

The level of anonymity can be determined by referring to the table below.

Given an application example, you can hang up a proxy and try the effect: http://ip.mixsec.org/

1. Situation without using proxy server:

REMOTE_ADDR = your IP
HTTP_VIA = No value or not displayed
HTTP_X_FORWARDED_FOR = No value or not displayed

2. The use of transparent proxy servers: Transparent Proxies

REMOTE_ADDR = proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = your real IP
This type of proxy server still forwards your information to the person you are visiting, and cannot achieve the purpose of hiding your true identity.

3. The situation of using ordinary anonymous proxy servers: Anonymous Proxies

REMOTE_ADDR = proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = Proxy server IP
Hide your real IP, but reveal to the target that you are using a proxy server to access them.

4. The use of deceptive proxy servers: Distorting Proxies

REMOTE_ADDR = proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = Random IP
Tell the visitor that you are using a proxy server, but make up a fake random IP instead of your real IP to trick it.

5. The use of high-anonymity proxy servers: High Anonymity Proxies

REMOTE_ADDR = proxy server IP
HTTP_VIA = No value or not displayed
HTTP_X_FORWARDED_FOR = No value or not displayed
Completely replaces all your information with the proxy server's information, just like you are using that proxy server to directly access the object.

In addition, proxy judges can be used to summarize some other reference judgment information and use it in practice.

Finally write a php example for your reference only:

Copy code The code is as follows:

if(!empty($_SERVER['HTTP_VIA'])) //A proxy is used
{
If(!isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
                    //Anonymous Proxies                                                                                         //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 high-anonymity proxy
{
//The real ip address is $_SERVER['REMOTE_ADDR']
}

http://www.bkjia.com/PHPjc/939413.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/939413.htmlTechArticlePHP implements detection of whether the client uses a proxy server and its anonymity level. The php proxy server must determine whether the client uses a proxy. The server can receive environment variable information from the client...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template