2.4-nginx prohibit designation of User_agent

Source: Internet
Author: User
Tags server website

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.