Portal Home > Knowledgebase > Frequently Asked Questions > Block whole country with CSF firewall or Apache .htaccess

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

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
VPS with Paysafecard (Views: 5389)

* Minimum sign up periods for cPanel Web Hosting plans: Mini - 3mo., Pro - 1mo., Biz - 1mo., cPanel Reseller Hosting, Linux VPS, Windows VPS, Managed cPanel VPS and Dedicated Servers - 1mo. secret link
Accepted payments: Credit/Debit Card, Paypal, Payza, Skrill, WebMoney, CashU, Ukash, paysafecard, Bitcoin, Perfect Money, SolidTrust Pay, OKPay, EgoPay, Western Union/MG, Wire Transfer and more.