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

  • 95 Users Found This Useful
Was this answer helpful?

Related Articles

How to clear your DNS cache

Windows: Start >> Run In the run box type the following: ipconfig /flushdns You may...

VPS with EgoPay

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

What are the DNS servers I should use

QHoster uses geographically independent DNS servers, which guarantees 100% of their...

VPS with Paysafecard

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

Unlimited web hosting

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