来自引荐来源网址的Nginx块 [英] Nginx block from referrer
本文介绍了来自引荐来源网址的Nginx块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要阻止所有具有引荐来源网址click2dad.net的http连接. 我在mysite.conf中写:
I need block all http connections, who have referrer click2dad.net. I write in mysite.conf:
location / {
valid_referers ~.*http://click2dad\.net.*;
if ($invalid_referer = ''){
return 403;
}
try_files $uri $uri/ /index.php?$args;
}
但是我仍然在nginx日志中看到:
But i still see in nginx logs:
HTTP/1.1" 200 26984 "http://click2dad.net/view/VUhfCE4ugTsb0SoKerhgMvPXcmXszU"
200,而不是403
200, not 403
是否正确地阻止了来自click2dad.net的所有客户端?
As it is correct to block all clients from the click2dad.net ?
推荐答案
应注意,表达式将与"http://"或"https://"之后的文本进行匹配 http://nginx.org/en/docs/http/ngx_http_referer_module.html
It should be noted that an expression will be matched against the text starting after the "http://" or "https://" http://nginx.org/en/docs/http/ngx_http_referer_module.html
正确的配置:
location / {
valid_referers click2dad.net*;
if ($invalid_referer = ''){
return 403;
}
try_files $uri $uri/ /index.php?$args;
}
这篇关于来自引荐来源网址的Nginx块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文