本篇是lnmp加固中修改denyrobots.conf配置。
网站反爬虫robots的原因
1)不遵守规范的爬虫会影响网站的正常使用
2)网站上的数据是网站的重要资产
3)爬虫对网站的爬取会造成网站统计数据的污染
- 设置步骤
站点配置文件因为user-agent带有Bytespider爬虫标记,这可以通过Nginx规则来限定流氓爬虫的访问,直接返回403错误。
#forbidden Scrapy if ($http_user_agent ~* (Scrapy|Curl|HttpClient)) { return 403; } #forbidden UA if ($http_user_agent ~ "Bytespider|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|python-requests|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|^$" ) { return 403; } if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot") { return 403; } #forbidden not GET|HEAD|POST method access if ($request_method !~ ^(GET|HEAD|POST)$) { return 403; }
- 测试
在第三方vps上测试
1)第一次测试——模仿奇虎访问http
curl -I -A 'qihoobot' www.fanlog.org
主要原因是采用nginx stream导致
2)第二次测试——模仿奇虎访问https
curl -I -A 'qihoobot' https://www.fanlog.org
3)第三次测试——浏览器标识空
curl -I -A ' ' https://www.fanlog.org
4)第四次测试——正常chrome访问
curl -I -A 'chrome' https://www.fanlog.org
5)第五次测试-解决api.w.org问题
curl -I -A 'chrome' https://www.fanlog.org
补充说明:
1)UI收集
FeedDemon 内容采集 BOT/0.1 (BOT for JCE) sql注入 CrawlDaddy sql注入 Java 内容采集 Jullo 内容采集 Feedly 内容采集 UniversalFeedParser 内容采集 ApacheBench cc攻击器 Swiftbot 无用爬虫 YandexBot 无用爬虫 AhrefsBot 无用爬虫 YisouSpider 无用爬虫(已被UC神马搜索收购,此蜘蛛可以放开!) jikeSpider 无用爬虫 MJ12bot 无用爬虫 ZmEu phpmyadmin 漏洞扫描 WinHttp 采集cc攻击 EasouSpider 无用爬虫 HttpClient tcp攻击 Microsoft URL Control 扫描 YYSpider 无用爬虫 jaunty wordpress爆破扫描器 oBot 无用爬虫 Python-urllib 内容采集 Python-requests 内容采集 Indy Library 扫描 FlightDeckReports Bot 无用爬虫 Linguee Bot 无用爬虫
参考资料:
- https://cloud.tencent.com/developer/article/1616186
- https://www.rmnof.com/article/block-search-indexing/
- http://www.rrdaj.com/hzseo/seoxin-shou-ru-men-xue-xi/4164.html
- https://blog.csdn.net/weixin_43507959/article/details/106881315
- https://www.cnblogs.com/xiao987334176/p/12559101.html