hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : VPS Hosting : VPS Tutorials : How to Block certain countries from accessing your web site on WHM
Reply

VPS Tutorials Tutorials related to VPS.
Forum Jump

How to Block certain countries from accessing your web site on WHM

Reply Post New Thread In VPS Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-10-2012, 12:26 PM
Ruchirablog Ruchirablog is offline
WHT Addict
 
Join Date: Aug 2009
Location: Sri Lanka
Posts: 106
Cool

How to Block certain countries from accessing your web site on WHM


If you want to block certain countries from accessing your web site, there are many workarounds. The most popular and worst method is blocking by IP ranges. But this isn’t a effective solution because of the IP range allocations changes day by day and its almost impossible to find IP range data base of a big country for example like China. And even if you did that, it will slow down your server drastically because even the ranges are too high and iptables software on your server will have to crosscheck every users IP addresses from the blocked range database resulting in slow response times and increased server load.

Config Server Firewall ( CSF ) firewall is a most feature rich software firewall available for linux and it integrates with WHM ( Web Host Manager Cpanel) very easily, enabling loads of configurable options at your disposal. Installing this is very easy when compared to options it has and this provides GUI to control the options on WHM

In my case I wanted to block China from accessing a web site because we were receiving fairly large amount of SPAM registrations from Chinese IPs and our web site had no use for Chinese users as well. So in this guide I’ll explain how I blocked China ( same method goes for other countries/multiple countries as well ) from accessing our web site.

  • Requirements


Cpanel WHM access is required. So you will have to be administrator of your server to have access to this

  • Features


CSF firewall uses Maxmind geoIP data base to find the IP ranges to block, that’s the most well maintained database of IP ranges on internet. You can trust this because there is no other service available better than this.

  • Constraints


Adding multiple countries will slow down your server if you don’t have enough resources and if your site is really busy
  • Install CSF Firewall


Installing CSF firewall is extremely easy, just run these commands one by one on your SSH console

Code:
    wget http://www.configserver.com/free/csf.tgz
    tar -xzf csf.tgz
    cd csf
    sh install.sh

And that’s it. Installation is done, Now restart your server. Or just restart all the services from WHM.

To open the csf firewall control panel, log in to WHM and on the left side bar you will see “ConfigServer security & Firewall ” at the bottom and click on that.



After that you will be presented a control panel of CSF like this

Click image for larger version

Name:	csf firewall on cpanel.jpg
Views:	217
Size:	108.5 KB
ID:	22910

csf firewall on cpanel How to Block certain countries from accessing your web site on WHM



To block countries, we need to edit the Firewall configuration and to do that click the “Firewall Configuration” button on that control panel.
Add Country/Countries to block list

After you click that “Firewall Configuration” button you will be taken to a place which will show many options in text format and we need to find the ” SECTION:Country Code Lists and Settings” on that page. Its there after you scroll for about 30% of the page.

Or just click Edit – > Find on your web browser and search for “Country” term and you will be able to easily find that section.


Click image for larger version

Name:	csf country block.jpg
Views:	199
Size:	139.6 KB
ID:	22911


csf country block How to Block certain countries from accessing your web site on WHM

On that you can see a box saying ” CC_DENY = ” like shown on the screencap above.

So to add countries to block list, you just need to add the 2 letter code of the countries to that box. In my Example I have added “CN” for China. So if you need to add multiple countries like USA , Germany and China just enter “CN,US,GB” on that box.



After adding scroll to the bottom of the page and click “change” button to save the changes. And restart the services using WHM.


Thats it!

I have originally published this on my blog here
http://www.ruchirablog.com/block-cer...b-site-on-whm/

You can find my other guide about installing squid as a ultrafast proxy to browse blocked web sites here.
http://www.webhostingtalk.com/showthread.php?t=1011438

Reply With Quote


Sponsored Links
  #2  
Old 07-11-2012, 05:14 AM
Farbyte Farbyte is offline
WHT Addict
 
Join Date: Jun 2010
Location: Manchester, UK
Posts: 138
Good post, we like CSF
You can also use 'IP Deny Manager' in cPanel to block IP ranges from accessing your website. This uses .htaccess though, so CSF is preferred as it employs iptables, thus completely blocking access to the server from the banned IP/range.

Reply With Quote
  #3  
Old 07-11-2012, 04:26 PM
Acroplex Acroplex is offline
What, me worry?
 
Join Date: Mar 2002
Location: Orlando, FL
Posts: 12,139
Caution though: blocking a country the size of China means a LOT of IP ranges will be parsed. This can take a toll on your server's performance and it's recommended for dedicated servers only.

Reply With Quote
Sponsored Links
  #4  
Old 07-14-2012, 05:34 AM
regex regex is offline
Newbie
 
Join Date: Jul 2012
Location: Nelson, NZ
Posts: 14
At one stage, I was blocking China, India and Russia through CloudFlare. Within one month, my traffic started to tank, even though very little of the the "real traffic" reported by GA comes from these countries. This makes me wonder if Googlebots in these countries were denied, and if this somehow affected global PageRank.
No longer using CF by the way.

Reply With Quote
  #5  
Old 07-16-2012, 12:55 PM
damoncloudflare damoncloudflare is offline
Web Hosting Master
 
Join Date: Nov 2010
Location: San Francisco, CA
Posts: 654
Post Hi,

Quote:
Originally Posted by regex View Post
At one stage, I was blocking China, India and Russia through CloudFlare. Within one month, my traffic started to tank, even though very little of the the "real traffic" reported by GA comes from these countries. This makes me wonder if Googlebots in these countries were denied, and if this somehow affected global PageRank.
No longer using CF by the way.
We actually have Google's IPs listed in our macro and wouldn't be blocking the Google bots. The only time there is really an issue is if they start crawling from new IPs, which they don't announce, so this would be generally a very temporary problem until we get the new IPs in our macro.

Reply With Quote
  #6  
Old 07-16-2012, 05:06 PM
regex regex is offline
Newbie
 
Join Date: Jul 2012
Location: Nelson, NZ
Posts: 14
This is going to get off-topic, but I have to respond.

Quote:
We actually have Google's IPs listed in our macro and wouldn't be blocking the Google bots.
I know, in theory CF sounds excellent.
It just didn't work out for me at all. My site was never down without CF, but with CF it was down quite a few times (not just mine but others on the CF forum), which really freaked me out. During the beta everything was fine, but after the release problems started, and I soon left the service. But maybe everything has been fixed now and it is working perfectly. In any case, I won't be going back.

Reply With Quote
  #7  
Old 07-16-2012, 05:15 PM
damoncloudflare damoncloudflare is offline
Web Hosting Master
 
Join Date: Nov 2010
Location: San Francisco, CA
Posts: 654
Post

Quote:
Originally Posted by regex View Post
This is going to get off-topic, but I have to respond.



I know, in theory CF sounds excellent.
It just didn't work out for me at all. My site was never down without CF, but with CF it was down quite a few times (not just mine but others on the CF forum), which really freaked me out. During the beta everything was fine, but after the release problems started, and I soon left the service. But maybe everything has been fixed now and it is working perfectly. In any case, I won't be going back.
Sorry to hear that. A lot has changed, notably over the past six months or so, and a lot of the issues people faced after the public release are pretty much fixed.

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing a web site Billy10 Web Hosting 17 03-05-2010 09:11 AM
Preventing other countries from accessing your site? ludachris Dedicated Server 6 02-09-2007 07:17 AM
Block countries from accessing the server by APF zoomx Hosting Security and Technology 1 10-06-2005 12:41 PM
How to block countries from accessing my site superprogram Hosting Security and Technology 7 12-12-2004 05:38 PM
How to block an IP from accessing the server? ymfm Hosting Security and Technology 4 05-11-2004 05:58 PM

Related posts from TheWhir.com
Title Type Date Posted
FireHost Report Shows Cross-Site Scripting Attacks Up 160 Percent from Q3 Web Hosting News 2013-01-30 14:43:57
Liquid Web Updates Block Storage, Adding Scale, Cross Mounting Web Hosting News 2012-12-14 16:17:44
FireHost Report Shows SQL Injections Up 69 Percent Over Q1 2012 Web Hosting News 2012-07-24 16:48:13
.XXX Domain Sunrise Period Opens Wednesday Web Hosting News 2011-09-06 20:50:41
US-CERT Publishes Recommendations for Preventing Cyber Security Attacks Web Hosting News 2011-07-22 19:07:35


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?