Is there any way to build a script which detects or rates proxies like Maxmind's proxy detection software?

I have already tried to use this code, but it doesn't detect all proxies, in fact it detect quite a low amount of proxies, while Maxmind can detect a lot more.

        || gethostbyaddr($_SERVER['REMOTE_ADDR']) == "."
        || $_SERVER['HTTP_VIA']
        || $_SERVER['HTTP_CLIENT_IP']
        || $_SERVER['VIA']
        || $_SERVER['X_FORWARDED_FOR']
        || $_SERVER['FORWARDED_FOR']
        || $_SERVER['CLIENT_IP']
        || in_array($_SERVER['REMOTE_PORT'], array(8080,80,6588,8000,3128,553,554))
        || @fsockopen($_SERVER['REMOTE_ADDR'], 80, $errno, $errstr, 0)
        echo 'proxy';
        echo 'no proxy';

Any solutions?


2 Answers 2


There is no sure way to detect proxy/vpn usage. Aside from what you've done (which won't catch many users tbh), the biggest bang for your buck will be an IP blacklist (which is most likely how maxmind are detecting proxies).

Here are some sites that offer IP blacklisting (I have no experience with any of them):

There are other tricks you can do to attempt to detect web proxies (like google translate, etc), which sometimes add extra headers. The problem is you'd have to add special cases for all of the ones that do (and most don't in any case).

  • There are some new stuff that came out recently for free: [W I T C H] (medium.com/@ValdikSS/…) - that's able to run on the server side and detect OpenVPN connections due to their unique MSS values. Combine it with p0f, you're able to pull quite a bit of information. getIPIntel - Uses block lists + machine learning and statistics to detect if an IP is a proxy and/or VPN via a simple API.
    – S W
    Aug 14, 2015 at 9:50
  • A good technique for detecting proxies and VPNs is using WebRTC to reveal a hidden IP address such as this class on GitHub. Another service that offers free proxy detection is IPQualityScore.com which detects proxies through WebRTC, headers, blacklists, and other tests.
    – Stas
    Jul 2, 2017 at 10:50

I know this post are old just for someone find this post on google

Check about dnsbl many server are free to use

I use few dnsbl server and many vpn proxy and tor are blocked on my website I recommand to keep for a specific time in a database the user ip so when he continu to visit your website he can load faster. Mine took aroud 5 to 10 second before I do that , Now with the DB every user load faster after the first loading

1- check in your DB if you find the ip. (is inside go step 2 , not go step 4)

2- if is inside ,check the added date if he overpass your time limit , delete the ip and resend a request.(if is in your time limit go step 3 , is overpass go step 4)

3- check in the DB if the ip are blocked (yes stop the script there , no load the page ).

4- ip outdated or no inside the DB send a request to the dnsbl server.

5- check his answer and add the ip in the DB with the current time and if his banned or not

6- load your page like step 3

Not the answer you're looking for? Browse other questions tagged or ask your own question.