Nginx blocking blank user agent.
Sometime apps ' Backgroud request always visit a URL, and these requests ' user agent was black, so I want block them.
Nginx Configuration for a location
location / { if ($http_user_agent""){ access_log off; return403; } default_type text/html; ' ngx.say("你好 baby
") '; }
Impersonation Request
lzz@ubuntu:conf$ 'http://localhost'
你好 baby </h1>
lzz@ubuntu:conf$ curl -H "User-Agent:" 'http://localhost'<html><head><title>403 Forbidden
title>
head><bodybgcolor="white"><center><h1>403 Forbidden
h1>
center><hr><center>ngx_openresty/1.2.6.1
center>
body>
html>
Statement:
This article is from the "Orangleliu Notebook" blog, reproduced please be sure to keep this source http://blog.csdn.net/orangleliu/article/details/44861585
Author Orangleliu using Attribution-NonCommercial-sharing protocol in the same way
The above describes the [nginx] on the UA is empty request returned 403, including the content, I hope to be interested in the PHP tutorial friends helpful.