Detect clients with Proxy Servers via PHP
You can't detect that unless they pass on special headers which explictly mention it like X-Forwarded-For or something.
As far as I know you have to use a blacklist. Users who use putty portforwarding, VPN or other more sophisticated methods are undetactable as they behave exactly like normal users.
Detecting whether a user is behind a proxy
TOR does not supply any server headers such as X_FORWARDED_FOR, so your best bet is to use a list of all known exit nodes. A list can be found at https://torstat.xenobite.eu/.
For other proxies, you can look at server headers. Possible server headers of interest include:
HTTP_VIA
HTTP_X_FORWARDED_FOR
HTTP_FORWARDED_FOR
HTTP_X_FORWARDED
HTTP_FORWARDED
HTTP_CLIENT_IP
HTTP_FORWARDED_FOR_IP
VIA
X_FORWARDED_FOR
FORWARDED_FOR
X_FORWARDED FORWARDED
CLIENT_IP
FORWARDED_FOR_IP
HTTP_PROXY_CONNECTION
In PHP, you can get the value of these fields in the $_SERVER[] superglobal
.
Finding IP address of client connected through a proxy
The standard solution (in php) is:
if ($_SERVER['HTTP_X_FORWARDED_FOR']){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else{
$ip = $_SERVER['REMOTE_ADDR'];
}
But as the first answer says this all depends on the header actually being set.
Related Topics
Swift Httppost Data Not Inserting to MySQL Database
Reordering Checkout Fields in Woocommerce 3
Print Newline in PHP in Single Quotes
How to Get Wkhtmltopdf to Execute via PHP
How to Call the Constructor with Call_User_Func_Array in PHP
Casperjs Passing Data Back to PHP
Return the Portion of a String Before the First Occurrence of a Character in PHP
Escape String to Use in Mail()
Mysqli Prepared Statements with in Operator
PHP Inserting Multiple Checkbox and Textbox Arrays into MySQL Database
Understanding Ioc Containers and Dependency Injection
Finding the PHP File (At Run Time) Where a Class Was Defined
What Factors Make PHP Unicode-Incompatible
PHP Can't Connect to MySQL with Error 13 (But Command Line Can)