Results 1 to 9 of 9
  1. #1

    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

  2. #2
    Quote Originally Posted by new2world View Post
    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
    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();}
    Add the country short codes to the array list as shown above, only those countries would be able to see your site, any others would just see a blank page.

    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.

  3. #3
    Cloudflare doesn't support country ban anymore . Unless buy enterprise which is out of my range.

  4. #4
    Quote Originally Posted by new2world View Post
    Cloudflare doesn't support country ban anymore .
    Hence the php code, it does the banning for you... well not really banning but whitelisting certain countries that you define.
    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.

  5. #5
    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

  6. #6
    <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?

  7. #7
    Quote Originally Posted by new2world View Post
    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
    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.

  8. #8
    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?

  9. #9
    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

  1. How to allow only one ip downloading files from a directory at a time.
    By prodj in forum Hosting Security and Technology
    Replies: 1
    Last Post: 10-19-2007, 06:47 PM
  2. two url pointing to same apache dir. How to allow only one to work?
    By nand in forum Hosting Security and Technology
    Replies: 4
    Last Post: 08-03-2005, 01:05 AM
  3. To allow overselling, or not to allow
    By w3bdesign in forum Reseller Hosting
    Replies: 33
    Last Post: 12-31-2004, 09:33 AM
  4. Allow only certain ip to connect to telnet
    By Rockerhard in forum Hosting Security and Technology
    Replies: 2
    Last Post: 03-06-2003, 01:43 AM
  5. Is it possible to allow only some commands?
    By MultiVol in forum Hosting Security and Technology
    Replies: 14
    Last Post: 09-01-2002, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •