本章目录
[TOC]
0x00 Nginx 封禁 DataForSeoBot、SemrushBot、AhrefsBot、MJ12bot 等恶意爬虫方法
前面简述: 今天早上发现博客网站流量出现异常,登录到服务器后查看nginx日志发现,被 DataForSeoBot 爬虫恶意拉取了博客中的文章,遂出现本文。
WeiyiGeek.恶意爬虫图
DataForSeoBot、SemrushBot、AhrefsBot、MJ12bot 在 Google 后发现是国外的 SEO 爬虫,这些恶性爬虫不会带来流量,还因为大量的抓取请求,造成主机的CPU和带宽资源浪费,所以需要对其屏蔽。
如何屏蔽无用的垃圾蜘蛛爬虫?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
User-agent: AhrefsBot Disallow: / User-agent: DotBot Disallow: / User-agent: SemrushBot Disallow: / User-agent: Uptimebot Disallow: / User-agent: MJ12bot Disallow: / User-agent: MegaIndex.ru Disallow: / User-agent: ZoominfoBot Disallow: / User-agent: Mail.Ru Disallow: / User-agent: SeznamBot Disallow: / User-agent: BLEXBot Disallow: / User-agent: ExtLinksBot Disallow: / User-agent: aiHitBot Disallow: / User-agent: Researchscan Disallow: / User-agent: DnyzBot Disallow: / User-agent: spbot Disallow: / User-agent: YandexBot Disallow: /
User-agent:* Allow: / Allow: /archives/ Allow: /tag/ Allow: /about/ Allow: /links/ Allow: /page/ Allow: /tools/ Disallow: /images/ Disallow: /fonts/ Disallow: /*.js Disallow: /*.css
Sitemap: https://blog.weiyigeek.top/sitemap.xml Sitemap: https://blog.weiyigeek.top/baidusitemap.xml
|
- 2.在 Nginx 站点子配置文件中判断头返回指定响应码
1 2 3 4 5
|
if ( $http_user_agent ~* "DataForSeoBot|SemrushBot|python|MJ12bot|AhrefsBot|AhrefsBot|hubspot|opensiteexplorer|leiki|webmeup" ){ return 403; }
|