我获得的某种访问权限导致我的服务器出现问题:
172.68.28.210 - - [03/Jul/2016:13:41:06 -0300] " "GET / HTTP/1.1" 502 166 "-" "-"
我什至想阻止 $HTTP_USER_AGENT,但这次尝试没有成功。
if ($http_user_agent = "-") {
return 403;
}
有人会知道出了什么问题吗?
最佳答案
这是因为 $http_user_agent
变量可能根据上下文具有不同的值。
如果请求中不存在 header ,则 it'll present itself as -
in your access_log
,同时 if 语句中仍然是空的。
因此,也许以下才是您想要的:
if ($http_user_agent = "") {
return 403;
}
关于Nginx 阻止用户代理 "-",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38172128/