Block visitors from using proxies with IP2Proxy PHP Module

Block visitors from using proxies with IP2Proxy PHP Module

While there are legitimate reasons for website visitors to use a proxy server when surfing on a website, there are those who have more malicious intent such as fraudsters. For an online store, it is better to block users who connect to the website via proxy servers. Often, such people are planning to commit payment fraud, hence the need to hide their identities with the use of anonymous proxies.

Protect your store with IP2Proxy PHP Module

For the purpose of this article, we will assume that your website is a PHP-driven website as PHP is a popular platform for e-commerce sites. We will demonstrate how you can easily detect when someone is visiting your web store using a proxy server. With a few lines of codes, you can block such visitors from accessing your webpages.


Installation steps

  1. Install Composer by following the steps from the above link
  2. Run composer require ip2location/ip2proxy-php in your website directory to install the IP2Proxy PHP Module
  3. Download either the commercial IP2Proxy BIN file from or the free LITE BIN file from
IP2Location LITE database

In the PHP page that you want to block access, add the following codes at the top of the page:

require 'vendor/autoload.php';
$db = new \IP2Proxy\Database();

$proxyType = $db->getProxyType($_SERVER['REMOTE_ADDR']);

If (preg_match('/^(VPN|TOR|DCH|PUB|WEB|SES|RES)$/', $proxyType) === 1) {

It is as simple as that to block various types of proxy servers from accessing your website. You can also choose which types of proxies you wish to block instead of blocking all of them.

Types of proxy servers supported

VPN – Anonymizing VPN services. These services offer users a publicly accessible VPN for the purpose of hiding their IP address.

TOR – Tor Exit Nodes. The Tor Project is an open network used by those who wish to maintain anonymity.

DCH – Hosting Provider, Data Center or Content Delivery Network. Since hosting providers and data centers can serve to provide anonymity, the Anonymous IP database flags IP addresses associated with them.

PUB – Public Proxies. These are services which make connection requests on a user’s behalf. Proxy server software can be configured by the administrator to listen on some specified port. These differ from VPNs in that the proxies usually have limited functions compare to VPNs.

WEB – Web Proxies. These are web services which make web requests on a user’s behalf. These differ from VPNs or Public Proxies in that they are simple web-based proxies rather than operating at the IP address and other ports level.

SES – Search Engine Robots. These are services which perform crawling or scraping to a website, such as, the search engine spider or bots engine.

RES – Residential proxies. These services offer users proxy connections through residential ISP with or without consents of peers to share their idle resources. Only available with PX10.

Was this article helpful?

Related Articles