homepage Welcome to WebmasterWorld Guest from 54.205.207.53
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

    
Blocking Site For A Country
SunnyG



 
Msg#: 4455241 posted 7:37 am on May 19, 2012 (gmt 0)

Hello all,
I need your help on my odd question. Actually one of my friends wants to create a website but that should be blocked for a Country. I mean he wants his site should not be accessed by a particular country users.

Technically is this possible?

I am puzzled ! So I need your help if this is possible.

Thanks

 

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4455241 posted 8:51 am on May 19, 2012 (gmt 0)

you can block IP addresses but not geographies.
depending on which country it can be simple or nearly impossible to define the IP range(s) associated with that country.
if your visitor is determined enough to access the site through a proxy on an unblocked IP address you're out of luck.

SteveWh

5+ Year Member



 
Msg#: 4455241 posted 9:12 am on May 19, 2012 (gmt 0)

Technically it is possible, but it's not as easy as one might wish. IP address ranges are not assigned by country, so any large range probably has smaller sub-ranges within it from a variety of different countries. That is, if you see an IP address from your banned country, you can't block all IPs starting with similar digits, because you'll probably be banning visitors from other countries, too.

In your web search for solutions, the keyword you need is "GeoIP" or maybe "geolocation". I believe that will lead you to databases and subscription lookup services that can translate an individual IP to its country of origin.

To implement on your server, you'll need to look up the IP of each incoming request to determine its country of origin. If it is the banned country, return a 403 response.

I believe there might be an Apache module that can carry out these lookups. Or if your code is all PHP, you can probably do it in PHP. However you do it, it probably adds significant overhead to the handling of each request.

An alternative to a subscription lookup service would be to manually build your own database of as many IP address ranges as you can find from the banned country (not an easy project, I suspect), and use your own code to consult that database for each request.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4455241 posted 10:00 am on May 19, 2012 (gmt 0)

if it's an apache server you can use a couple of methods of Access Control:
http://httpd.apache.org/docs/2.2/howto/access.html [httpd.apache.org]

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4455241 posted 12:47 am on May 20, 2012 (gmt 0)

IP address ranges are not assigned by country, so any large range probably has smaller sub-ranges within it from a variety of different countries. That is, if you see an IP address from your banned country, you can't block all IPs starting with similar digits, because you'll probably be banning visitors from other countries, too.

And how! Currently about 2/3 of the "Deny from..." section of my htaccess is devoted to The Unwanted Country-- and that's nowhere near a complete list. To keep things sane I cut off at /16 (that is, aa.bb) unless I meet an individual nasty in a smaller range. If I included everything, the list would be more than twice as long.

You could throw in a language block. But unless you're locking out a major European country-- somehow I doubt this is what you want to do-- the language probably won't even show up in the UA.

Kendo

5+ Year Member



 
Msg#: 4455241 posted 6:14 am on May 20, 2012 (gmt 0)

Blocking by language detected in the user-agent may be of use here.

SunnyG



 
Msg#: 4455241 posted 11:33 am on May 23, 2012 (gmt 0)

Thanks you all for taking time answer my query.

I have used Block by IP method :)

Thanks again.

sswebdesigner



 
Msg#: 4455241 posted 5:16 pm on Jun 14, 2012 (gmt 0)

on robots file?

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4455241 posted 8:50 pm on Jun 14, 2012 (gmt 0)

the only thing you can block in robots.txt is crawling by well-behaved bots.

jmccormac

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



 
Msg#: 4455241 posted 9:29 pm on Jun 14, 2012 (gmt 0)

If you are on a dedicated Linux server then it may be possible to block at the IP level using iptables or similar firewall software. This essentially prevents any traffic from the problem IPs ever getting to Apache. However with some countries you may be blocking thousands of IP ranges and you are not going to get a 100% solution due to the web proxy issue.

Regards...jmcc

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved