nigx屏蔽无用爬虫

大量恶意爬虫占用系统资源,频繁访问服务器快耗竭。快速屏蔽掉无用爬虫可以参考下面方法。

3.229.95.193 - - [28/Apr/2025:08:27:58 +0800] "GET /news/1563.html HTTP/1.1" 200 11642 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Amazonbot/0.1; +https://developer.amazon.com/support/amazonbot) Chrome/119.0.6045.214 Safari/537.36"

通过宝塔面板,伪静态重写,代码如下:

if (http_user_agent \~\* "SemrushBot/7\~bl\|YandexBot\|Amazonbot/0.1\|GPTBot/1.2\|GPTBot\|Bytespider\|meta-externalagent\|Amazonbot\|GPTBot\|Meta-ExternalAgent\|FeedDemon\|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;

}

重写之后,系统负载正常。

相关推荐
努力的搬砖人.1 天前
Spring Boot 使用 WebMagic 爬虫框架入门
java·spring boot·爬虫
小白学大数据1 天前
基于Python的携程国际机票价格抓取与分析
开发语言·爬虫·python
火龙谷2 天前
【爬虫】deepseek谈爬虫工具
爬虫
前端没钱2 天前
在Electron中爬取CSDN首页的文章信息
前端·javascript·爬虫·electron
YONG823_API3 天前
借助电商 API 接口实现电商平台商品数据分析的详细步骤分享
数据库·爬虫·microsoft·数据挖掘·数据分析
jiaoxingk3 天前
多线程爬虫中实现线程安全的MySQL连接池
爬虫·mysql·安全
不会飞的鲨鱼3 天前
Scrapy框架之CrawlSpider爬虫 实战 详解
爬虫·scrapy
API小爬虫4 天前
利用 Python 爬虫按关键字搜索 1688 商品详情:实战指南
开发语言·爬虫·python
Luck_ff08104 天前
【Python爬虫详解】第五篇:使用正则表达式提取网页数据
爬虫·python·正则表达式