I want to prevent people from certain countries from visiting my website - but I want to allow some defined IP addresses from those countries to be able to access it. Is it possible? If yes, how?
feedback
|
migrated from stackoverflow.com Jul 16 '09 at 22:41
This question came from our site for professional and enthusiast programmers.
|
You could deny access to a range of IP addresses known to originate from that country, while using a white list to enable access to those specific IP addresses which you want to allow. However, this could easily be subverted by, for example, using a proxy from a different country, or simply by going to a different country and then viewing the website from there. This is probably more trouble than it is worth. Also, you might want to verify that you are legally permitted to deny access on a country-wide basis. Not to mention, of course, the ethical implications of discriminating against users on the basis of nationality. | |||||||||||||
feedback
|
|
This is going to be pretty tough as a user could still use a proxy to bypass any checks you have that look at IP/location. | |||||
feedback
|
|
You could use some data like this: http://www.ipinfodb.com/ When you have that in place, you check to see if your guest matches a banned location, and if they do, only allow them if they are on a white list of ips. Of course, nothing you do will stop people from using a proxy if they really want to. | |||
|
feedback
|
|
The easiest way to solve this problem, using data like this(Click download on right-bottom of webpage) for converting user ip to country. | |||
|
feedback
|
|
I'd write some iptables (or use another type of firewall) and say : allow all, block this range EXCEPT if the IP can be found in my whitelist | |||
|
feedback
|