Home >Backend Development >PHP Tutorial >php HTTP_X_FORWARDED_FOR, HTTP_VIA, REMOTE_ADDR Difference Summary_PHP Tutorial
This article introduces a summary of the differences between HTTP_X_FORWARDED_FOR, HTTP_VIA, and REMOTE_ADDR in php when obtaining the user's real IP address.
1. The case of not using a 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 = Last proxy server IP
HTTP_VIA = Proxy server IP
HTTP_X_FORWARDED_FOR = Your real IP. When passing through multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
This type of proxy server still forwards your information to your visitor, which cannot achieve the purpose of hiding your true identity.
3. The situation of using ordinary anonymous proxy servers: Anonymous Proxies
REMOTE_ADDR = Last proxy server IP
HTTP_VIA = Proxy server IP
HTTP_X_FORWARDED_FOR = Proxy server IP. When passing through multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
Hides your real IP, but reveals to your visitors 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
HTTP_X_FORWARDED_FOR = Random IP. When passing through multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
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 (Elite proxies)
REMOTE_ADDR = Proxy server IP
HTTP_VIA = No value or not displayed
HTTP_X_FORWARDED_FOR = No value or not displayed. When passing through multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
Completely replaces all your information with the proxy server's information, just like you are using that proxy server to directly access the object
Example 1 (Get the user’s real IP address)
The code for HP to obtain the user’s real IP address is as follows
The code is as follows | Copy code | ||||
|
例子2
代码如下
|
复制代码 | ||||
/*
$ip = getenv("REMOTE_ADDR"); else