[nginx] 对UA为空的请求返回403
程序员文章站
2024-01-09 21:07:34
...
nginx blocking blank user agent .
sometime apps’ backgroud request always visit a url, and these requests’ user agent is black, so I want block them.
针对一个location的nginx配置
location / {
if ($http_user_agent = ""){
access_log off;
return403;
}
default_type text/html;
content_by_lua '
ngx.say("你好 baby
")
';
}
模拟请求
lzz@ubuntu:conf$ curl 'http://localhost'
你好 baby /h1>
上一篇: 大数据征信:*数据该如何开放
下一篇: android之换头像及遇到的一些坑