Block whole country with CSF firewall or Apache .htaccess

There are lot of ways to block users to access your web sites but we will mention only two of them. First one is to use mod_geoip for Apache web server if you are on VPS hosting server or dedicated server. After you have the Apache module compiled just use your .htaccess file to block whole countries IP addresses. The second way is to use CSF firewall which is based on Linux iptables firewall.

Using VPS hosting or dedicated Server blocking whole countries IP address ranges using the firewall is a lot better alternative for you. Also the overhead for the VPS server or dedicated server is a lot less. This will save you some CPU power and RAM memory resources. If you like to ban countries like China, Turkey or Iraq like you do not like to ship a goods to there for some reason, you can block the whole country IP addresses from accessing the web sites on your server. This may help you too to reduce the number of fraudulent orders for your online store.

Will will show you the steps you need to do on your VPS or dedicated server hosting when using ConfigServer Security & Firewall (CSF) based on iptables:

1. Open the cPanel's WHM admin panel for your VPS server or dedicated server and find "ConfigServer Security&Firewall" link
2. Click the "Firewall Configuration" button after that
3. Scroll down the page or use the "find" option in your web browser to the section with text "CC_DENY". These are comma separated list of 2 letter country codes. You can find the country codes at - http://www.worldatlas.com/aatlas/ctycodes.htm
4. For every country IP address range you like to deny/block, just enter those letters in the field in the way separated by commas

  • 88 Users Found This Useful
Was this answer helpful?

Related Articles

Do you support SSI (server side includes) on html pages

Yes we do. SSI or Server Side Includes is supported by all hosting plans.  

Who will transfer my data from the old web hosting provider

If your old web hosting provider uses cPanel, it is best to do a full backup. Then you can send...

Unlimited web hosting

We do not offer unlimited web hosting or hosting with unlimited disk space and traffic. From...

Activate AWStats In cPanel

AWStats is a powerful statistics program and one important utility in your cPanel web hosting...

How to install Joomla

First download the latest version of Joomla from Joomla. Then follow the installation steps...