Welcome to WebmasterWorld Guest from 54.227.1.130

Forum Moderators: phranque

Message Too Old, No Replies

Blocking Site For A Country

     

SunnyG

7:37 am on May 19, 2012 (gmt 0)

5+ Year Member



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

8:51 am on May 19, 2012 (gmt 0)

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



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

9:12 am on May 19, 2012 (gmt 0)

5+ Year Member



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

10:00 am on May 19, 2012 (gmt 0)

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



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

12:47 am on May 20, 2012 (gmt 0)

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



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

6:14 am on May 20, 2012 (gmt 0)

10+ Year Member



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

SunnyG

11:33 am on May 23, 2012 (gmt 0)

5+ Year Member



Thanks you all for taking time answer my query.

I have used Block by IP method :)

Thanks again.

sswebdesigner

5:16 pm on Jun 14, 2012 (gmt 0)



on robots file?

phranque

8:50 pm on Jun 14, 2012 (gmt 0)

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



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

jmccormac

9:29 pm on Jun 14, 2012 (gmt 0)

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



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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month