如何阻止所有非美国IP地址访问我的网站?

问题描述:

我想阻止所有非美国用户访问我的网站。我在前端使用nginx,并拥有一个由django支持的网站。

I want to block all non-US users from accessing my website. I'm using nginx on the front end and have a django powered website.

1)我如何确定什么是美国IP地址?

1) How can I determine what are US IP addresses?

2)是否应将其阻止在我的Web服务器还是我的应用程序层?

2) Should I be blocking them in my webserver or in my application layer?

我使用了mod_geoip,发现它在很大程度上但并非完全有效。 IP /国家/地区数据库的准确性是一个问题,而保持该数据库的最新状态也是如此。我还发现,尽管它有助于缓解来自世界各地与我们网站内容无关的某些评论垃圾邮件和DDOS类型查询,但它也会带来意想不到的后果。例如,有些人在国外度假时试图更新其网站列表,但被阻止。 http://www.maxmind.com/app/mod_geoip

I've used mod_geoip and found it to be largely but not completely effective. The accuracy of the IP / country database is one issue, as is keeping that database up-to-date. I also found that while it helped mitigate some comment spam and DDOS type queries coming from parts of the world not relevant to the content of our site, it also had some unintended consequences. For instance, there were people who attempted to update their site listings while on vacation overseas who were blocked. http://www.maxmind.com/app/mod_geoip