A simple way to configure the user-agent of a filter crawler in Nginx _nginx

Source: Internet
Author: User

In the past, when blogging, the server downtime, the Web page is not all out, but ping the server when it can ping. Login ssh looked down at top, stunned, average load 13 12 8. Do you think I'm being DDoS for a moment? Look at the next process is basically PHP-FPM CPU to take up, to see the log it ...

A look is very, basically is a user agent called "Yisouspider" things to brush screen, a look do not know which spider, too no moral integrity.
Find the root configuration area, add User Agent filter Judgment statement, found that "Yisouspider" direct return 403

Note 1: If you need to add more filters, do this

 

, the middle used | to separate the line

NOTE 2: If you are using a subdirectory blog, like mine, then find a section like "location/blog/" to modify

Location/{
... Other configuration
if ($http _user_agent ~* "Yisouspider") {return
403;
}
}

Configuration complete Wq Save reload after the Nginx, and then use the following command self test, address change. Did not install curl I have no way, oneself apt or yum to install a bar, artifact comes.

Curl-i-A "Yisouspider" www.slyar.com/blog/

See the return of 403 on it, indicating that the configuration was successful

PS: Some common reptiles of the user-agent, these generally do not filter the ~
Baidu Crawler
* baiduspider+ (+http://www.baidu.com/search/spider.htm ")

Google crawler
* MOZILLA/5.0 (compatible; googlebot/2.1; +http://www.google.com/bot.html)
* googlebot/2.1 (+http://www.googlebot.com/bot.html)
* googlebot/2.1 (+http://www.google.com/bot.html)

Yahoo crawler (Yahoo China and U.S. headquarters, respectively)
*mozilla/5.0 (compatible; Yahoo! Slurp; Http://misc.yahoo.com.cn/help.html ")
*mozilla/5.0 (compatible; Yahoo! Slurp; Http://help.yahoo.com/help/us/ysearch/slurp ")

Sina love to ask a reptile
*iaskspider/2.0 (+http://iask.com/help/help_index.html ")
*mozilla/5.0 (compatible; iaskspider/1.0; MSIE 6.0)

Sogou crawler
*sogou Web spider/3.0 (+http://www.sogou.com/docs/help/webmasters.htm#07″)
*sogou Push spider/3.0 (+http://www.sogou.com/docs/help/webmasters.htm#07″)

NetEase crawler
*mozilla/5.0 (compatible; yodaobot/1.0; Http://www.yodao.com/help/webmaster/spider/"; )

MSN Crawler
*msnbot/1.0 (+http://search.msn.com/msnbot.htm ")

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.