题
我运行两个杂种在一个配置服务器。我不断收到请求对一个不存在的文件。IP地址变更频繁地引用URL保持不变。我想解决这个问题。
解决方案
<强> https://calomel.org/nginx.html 强>
阻止大多数“垃圾参照” -
“以上的问题的烦恼的”<强> nginx.conf 强>
## Deny certain Referers (case insensitive)
## The ~* makes it case insensitive as opposed to just a ~
if ($http_referer ~* (babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo))
{ return 403; }
其他提示
使用的Nginx 地图模块是AA位更有效和更容易管理作为列表获取长。
<强>将这个在你的http {}块:强>
map $http_referer $bad_referer {
hostnames;
default 0;
# Put regexes for undesired referers here
"~social-buttons.com" 1;
"~semalt.com" 1;
"~kambasoft.com" 1;
"~savetubevideo.com" 1;
"~descargar-musica-gratis.net" 1;
"~7makemoneyonline.com" 1;
"~baixar-musicas-gratis.com" 1;
"~iloveitaly.com" 1;
"~ilovevitaly.ru" 1;
"~fbdownloader.com" 1;
"~econom.co" 1;
"~buttons-for-website.com" 1;
"~buttons-for-your-website.com" 1;
"~srecorder.co" 1;
"~darodar.com" 1;
"~priceg.com" 1;
"~blackhatworth.com" 1;
"~adviceforum.info" 1;
"~hulfingtonpost.com" 1;
"~best-seo-solution.com" 1;
"~googlsucks.com" 1;
"~theguardlan.com" 1;
"~i-x.wiki" 1;
"~buy-cheap-online.info" 1;
"~Get-Free-Traffic-Now.com" 1;
}
<强>将这个在服务器{}块:强>
if ($bad_referer) {
return 444; # emtpy response
}
这为我工作。
我已经在类似的情况之前,我需要阻止人们基于行为而不是其他的任意性的规则,一个防火墙可以在其自身。
他们的方法,我的工作围绕的问题是要让我的逻辑(轨道在你的情况)不阻止...但很长一段路:
- 有你的逻辑维持的方框列为一个新的线分离出纯文本文件。
- 创建一个庆典(或其他)脚本作为根阅读本文件和增加其listees到你的防火墙的黑名单
- 创建一个定时的工作,以叫剧本,再次作为根
我之所以这样做围(而不是仅仅给予它的权限,以改变的防火墙config)是简单:安全。如果我的申请被砍死,我不想要伤害其他任何东西。
Bash脚本是这样的:
exec < /path/to/my/djago-maintained/block-list
while read line
do
iptables -A INPUT --source $line/32 -j DROP
done
我已经创建模块,用于检查在黑名单传入IP https://github.com/oneumyvakin/ngx_http_blacklist_lookup_module一>
它使用黑名单从projecthoneypot.org,blocklist.de和uceprotect.net
不隶属于 StackOverflow