Home  >  Article  >  Backend Development  >  php detect proxy instance code

php detect proxy instance code

怪我咯
怪我咯Original
2017-07-16 11:15:162448browse

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;  
}  
?>


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!

Statement:
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