User_agent code used to identify the visitor's operating system (including version number) browser (including version number) and user preferences
For example , our server website, will be some search engine crawler program Access, which has a certain impact on the server pressure. We can prohibit it from visiting the website according to the user_agent mark of the crawler.
You can use the location statement or not. Insert the following code globally.
#全局配置黑名单, access to websites is forbidden
# Deny 127.0.0.1;
# Deny 192.168.1.0/24;
if ($http _user_agent ~* ' curl|baidu|111111 ') #~ match ~* to ignore case match
{
return 403;
}
Test:
curl-x192.169.11.101:80 Www.llzdwyp.com-I Display 403 Forbidden
Curl-a "LLZDWYP"-x192.168.11.101:80 Www.llzdwyp.com-I analog User_ageng for LLZDWYP, showing 301 normal
Open Web page with 360 browser, display normal. Because User-agent is Mozilla.
2.4-nginx prohibit designation of User_agent