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 -
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

  • 82 Users Found This Useful
Was this answer helpful?

Related Articles

How to transfer my domain name and web site

To transfer your domain and/or web site to us, it is necessary to place an order through the...

When I will be able to use the hosting services that I paid for

Once the payment for order is confirmed, they shall be activated immediately. Information for...

Activate AWStats In cPanel

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

VPS with WebMoney

QHoster accepts WebMoney for all VPS services! You can buy Linux or Windows VPS and pay...

VPS with Payza

QHoster accepts Payza for all VPS services! You can buy Linux or Windows VPS and pay with Payza...