Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to completely detect Proxies using PHP

I would like to fully detect proxies before someone enters to my website, to prevent fraudulent actions.

Is there any script in PHP which could actually detect all proxies, like Transparent, Anonymous, High Anonymous, Socks, Tor, etc?

I have a code but I'm not sure that it filters all proxies:

$proxy_headers = array(
        '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'
    );
    foreach($proxy_headers as $x){
        if (isset($_SERVER[$x])) die("You are using a proxy!");
    }

Can someone help me to create a complete solution which can stop ANY proxy traffic coming to my website?

like image 834
Taboo Loco Avatar asked Dec 05 '25 13:12

Taboo Loco


1 Answers

I would like to fully detect proxies before someone enters to my website, to prevent fraudulent actions.

This makes no sense at all. There are plenty of totally legitimate use cases for proxies. Also, a malicious proxy user can remove those headers, and any other indication that they might be using a proxy.

The only really secure way for you to detect a proxy user would be to have a list of all proxy IPs that exist.

I would call this off, and spend my time on building more useful security measures. One that may become useful over time is the ability to easily block certain IPs or even IP ranges used by troublemakers.

like image 107
Pekka Avatar answered Dec 07 '25 02:12

Pekka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!