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配置
<code> location / { <span>if</span> (<span>$http_user_agent</span> = <span>""</span>){ access_log off; <span>return</span><span>403</span>; } default_<span>type</span> text/html; content_by_lua <span>' ngx.say("<h1>你好 baby </h1>") '</span>; }</code>
模擬請求 本文出自 “orangleliu筆記本” 博客,轉載請務必保留此出處http://blog.csdn.net/orangleliu/article/details/44861585
作者orangleliu 採用署名-非商業性使用-相同方式共享協議
以上就介紹了[nginx] 對UA為空的請求返回403,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。