Nginx Disable malicious UESR agent Access

Source: Internet
Author: User

Disabling some user agent can save some traffic can also prevent some malicious access, especially some search engine crawler, such as our site is a local site, there is no need to be some foreign search engine crawler index, can be banned, the specific operation is as follows:

1. Edit the file:
# vi/usr/local/nginx/conf/vhosts/yourpool.conf
2, add the following content (example):
#禁止Scrapy等工具的抓取, note that curl fetching has been canceled
if ($http _user_agent ~* (scrapy| curl| HttpClient)) {
return 403;
}
#禁止恶意user_agent访问
if ($http _user_agent ~ "feeddemon| jikespider| Indy library| Alexa toolbar| asktbfxtv| Ahrefsbot| crawldaddy| Coolpadwebkit| java| feedly| universalfeedparser| apachebench| Microsoft URL control| Swiftbot| zmeu|obot|jaunty| Python-urllib|lightdeckreports bot| yyspider| Digext| Httpclient| Mj12bot|heritrix| easouspider| ezooms|^$ ") {
return 403;
}
#禁止非GET | head| Post-mode fetching
if ($request _method!~ ^ (get| head| POST) ($) {
return 403;
}
There are some words in the middle of the space, so the two sides need to use double quotation marks, disable a number of search engine crawler, there are several malicious machine, etc., you can analyze the log according to the situation to block malicious user Agent.

Nginx Disable malicious UESR agent Access

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.