Results 1 to 9 of 9
-
07-06-2015, 06:11 PM #1Junior Guru
- Join Date
- Sep 2011
- Posts
- 216
How to allow only few countries to view the website?
Hi,
I would like to allow only 3-4 countries to view my website and block the rest of the countries.
Is there a way I can just put all those countries ip address and set some rule that only allow from these ips and anything else should be 404 page from vps or .htacess if it's not memory consuming.
Kindly let me know thanks
-
07-06-2015, 06:19 PM #2~~~~
- Join Date
- May 2008
- Posts
- 3,424
One way to do it is get your site behind cloudflare, and use this little php code at the top of your page:
Code:$allowed = array( 'RO', 'US', ); if(!in_array($_SERVER["HTTP_CF_IPCOUNTRY"],$allowed)) {die();}
It may not be the best way to do it, but it's what came up to me on the spot, as I've never had to whitelist countries before for any site
why would you even want to do that?Uptime Monitor - Minimize your downtime by being the first to know about it!
Blacklist Monitor - Are any of your IPs or Domains blacklisted? Find out before it gets to affect you or your clients.
-
07-06-2015, 06:20 PM #3Junior Guru
- Join Date
- Sep 2011
- Posts
- 216
Cloudflare doesn't support country ban anymore . Unless buy enterprise which is out of my range.
-
07-06-2015, 06:21 PM #4~~~~
- Join Date
- May 2008
- Posts
- 3,424
Uptime Monitor - Minimize your downtime by being the first to know about it!
Blacklist Monitor - Are any of your IPs or Domains blacklisted? Find out before it gets to affect you or your clients.
-
07-06-2015, 07:05 PM #5Junior Guru
- Join Date
- Sep 2011
- Posts
- 216
But this way bad guys can direct access the images etc that I don't want them to download So is there any vps way or .htacces way to block it
-
07-06-2015, 07:09 PM #6Junior Guru
- Join Date
- Sep 2011
- Posts
- 216
<Limit GET HEAD POST>
order deny,allow
deny from all
allow from 41.205.32.0/19
allow from ....
</LIMIT>
Will the above code work, If I add only certain countries ip list in allow section ? How much load it will generate for vps to handle?
-
07-06-2015, 07:11 PM #7~~~~
- Join Date
- May 2008
- Posts
- 3,424
I guess you can use a tool such as this one: http://www.ip2location.com/blockvisitorsbycountry.aspx
To generate your .htaccess file for you.
Select IPv4, below select the countries you wish to allow, and at the end select 'Apache .htaccess allow'.Uptime Monitor - Minimize your downtime by being the first to know about it!
Blacklist Monitor - Are any of your IPs or Domains blacklisted? Find out before it gets to affect you or your clients.
-
07-07-2015, 05:35 AM #8Junior Guru Wannabe
- Join Date
- Jan 2015
- Posts
- 42
I assume that is not hard to get integrated blocks of IPs which allowed to visit your web site. That is harder to get fresh lists of such IP. I have no idea where such lists could be found.
Do you have any idea?
-
07-07-2015, 05:37 AM #9WHT Addict
- Join Date
- Oct 2013
- Location
- AZ
- Posts
- 117
You can use config server firewall to block country codes also. Its what I do.
tier1webhosting.com Your SSD hosting Choice
Daily Backups - Fast SSD Servers - Secure -- VPS, Shared and Dedicated Servers
Download Test File http://tier1webhosting.com/100mb.test
Similar Threads
-
How to allow only one ip downloading files from a directory at a time.
By prodj in forum Hosting Security and TechnologyReplies: 1Last Post: 10-19-2007, 06:47 PM -
two url pointing to same apache dir. How to allow only one to work?
By nand in forum Hosting Security and TechnologyReplies: 4Last Post: 08-03-2005, 01:05 AM -
To allow overselling, or not to allow
By w3bdesign in forum Reseller HostingReplies: 33Last Post: 12-31-2004, 09:33 AM -
Allow only certain ip to connect to telnet
By Rockerhard in forum Hosting Security and TechnologyReplies: 2Last Post: 03-06-2003, 01:43 AM -
Is it possible to allow only some commands?
By MultiVol in forum Hosting Security and TechnologyReplies: 14Last Post: 09-01-2002, 09:55 AM