Home > Backend Development > PHP Tutorial > php detect proxy instance code

php detect proxy instance code

怪我咯
Release: 2023-03-14 07:14:02
Original
2489 people have browsed it

Proxy Server (Proxy Server) is an important server security function. It works mainly at the session layer of the Open System Interconnection (OSI) model , thus acting as a firewall. role. Proxy servers are mostly used to connect to the INTERNET (International Internet) and Local Area Network (LAN).

Proxy (English: Proxy), also known as network proxy, is a special network service that allows a network terminal (usually a client) to communicate with another network terminal (usually a server) through this service Indirect connection. Some network devices such as gateways and routers have network proxy functions. It is generally believed that proxy services are helpful to protect the privacy or security of network terminals and prevent attacks

The following code can detect most IPs accessed through the proxy server.

<?php  
//beiji.com   2000.6.17  
$ip = getenv("REMOTE_ADDR");  
$v = getenv("HTTP_VIA");  
$f = getenv("HTTP_X_FORWARDED_FOR");  
$c = getenv("HTTP_XROXY_CONNECTION");  
$o = getenv("HTTP_PRAGMA");  

print &#39;<br>REMOTE_ADDR&#39;;  
print $ip;  

if (($v=="")&&($f=="")&&($c=="")&&($o=="")){  
print "<br>not through proxy";  
}  
else {  
print "<br>through proxy";  
print &#39;<br>http_via: &#39;;print $v;  
print &#39;<br>http_x_forwarded_for: &#39;;print $f;  
print &#39;<br>http_xroxy_connection: &#39;;print $c;  
print &#39;<br>http_pragma: &#39;;print $o;  
}  
?>
Copy after login


The above is the detailed content of php detect proxy instance code. For more information, please follow other related articles on the PHP Chinese website!

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