如何阻止所有非美国IP地址访问我的网站? [英] How could I block all non-US IP addresses from access to my website?

查看:65
本文介绍了如何阻止所有非美国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

这篇关于如何阻止所有非美国IP地址访问我的网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆