Geo Restriction?

Events happening in the community are now at Drupal community events on www.drupal.org.
rjdempsey's picture

Hi all,

I'm working on a site at the moment where the client wants to allow access only to people within certain geographic limits. I know hulu.com only streams videos to the US and gives an alert to us Canadians. Specifically we want to allow access only to i.p. addresses in British Columbia, and provide a similar alert box to outsiders. Any ideas on how I can do this?

Thanks,

Ryan

Comments

Reverse lookups

atuline's picture

I don't know how to do it programmatically, but I'd do a reverse DNS lookup on the requestor's IP address.

For example, go to www.arin.net and enter an IP address in the Search Box.

If the StateProv result is BC, then you're good as gold.

MaxMind? or geoip API

mackh's picture

Programmatically, I've done this before using a service like MaxMind http://www.maxmind.com/app/ip-location but you'd still need to code something a bit custom for drupal to handle it.

So they're going to block

boris mann's picture

So they're going to block Google from the site? In general, this is probably a bad idea. I think it's a bad idea for Hulu, too, but that's a matter of IP / copyright.

There are a couple of different modules that do some geo stuff with IPs that you could likely get some code from. e.g. http://drupal.org/project/geostats

So, if (IP lookup) == BC, then show content else hide content, show message.

Sounds strange, but yes,

rjdempsey's picture

Sounds strange, but yes, he's happy to block google too. He feels he has a really unique idea and intellectual property that he doesn't want spreading too quickly. He wants to release it locally first.

I'll check both maxmind and the geostats module. Thanks!

Not a perfect solution

beanjammin's picture

Keep in mind that blocking based on IP is not perfect. For instance, I'm in N. Van but my ISP is based in Ontario. Checking GeoIP shows me in Toronto.

It's one thing to show tailored content based on where you think someone is, it's another to block them from your site. If you go this route you'll want to create a way to get around the blocking.

  • Ben

Do it at the server-level

mkelly's picture

Being a former sysadmin-type person, if I were building such a beast, and it was running on an Apache-based webserver, then I'd look at something like the mod_geoip plugin for Apache:

http://www.maxmind.com/app/mod_geoip

You can use this to redirect people to various URLs depending on their perceived geo-location. Keyword is perceived. As others have stated, geo-location by IP address is not a sure thing. I know many people here in Vancouver for instance that enjoy watching the latest Battlestar Galactica episode on Hulu.

That said, this Apache module will do the trick.

Vancouver

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: