Are you interested for monthly server support with Unlimited tickets, 24×7 monitoring, Security Audit and lot more ? please check our Monthly server support plans
Block certain countries from accessing your web site:
You can block the access over certain countries to your website. This can be achieved by using the apache module Geo IP module.
This can be easily install and configure in your cPanel server. The main advantage of this module is the possibility of blocking various countries using the country code.
This is done by a module named mod_Geoip on the Apache. Below are the steps to enable and configure Geo IP on a cPanel servers,
First install binaries for GeoIP.
yum install GeoIP GeoIP-devel
Then you can download databases from MaxMind and put them into /opt/geoip/share/GeoIP/
Now install cPanel EasyApache GeoIP module. For that,
Run EasyApache and select mod GeoIP from
Configure GeoIP by adding to httpd configuration file [ you can also add this to httpd conf by editing pre_virtualhost_global.conf from WHM]
/usr/local/apache/conf/httpd.conf /usr/local/apache/conf/includes/pre_virtualhost_global.conf LoadModule geoip_module modules/mod_geoip.so <IfModule mod_geoip.c> GeoIPEnable On GeoIPDBFile /var/lib/GeoIP.dat </IfModule>
Now install GeoIP PHP Extension using the command below,
pecl install geoip
Now test if it is enabled by adding rules for that on .htaccess file on the public_html of the website. For that,
Edit the .htaccess file and add the following codes to it,
SetEnvIF GEOIP_COUNTRY_CODE AF BlockThese
SetEnvIF GEOIP_COUNTRY_CODE PK BlockThese
# Add more countries here Deny from env=BlockThese
Here in the above code the country codes specified are,
AF and PK those belongs to countries AF Afghanistan and PK Pakistan.
You can see the list of all the country codes from the link below,
This is how to block the access of certain countries to your website.
Need our help to fix the issue ? Submit Support Ticket NowView Server Administration Packages