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;

}

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

相关推荐
wuyk5551 天前
Spider-第14讲-表单提交与CSRF
前端·爬虫·python·elasticsearch·csrf
wuyk5553 天前
Spider-第11讲-工程化改造与可维护性
大数据·爬虫·elasticsearch·搜索引擎
wuyk5553 天前
Spider-第12讲-asyncio异步并发爬取
大数据·爬虫·elasticsearch·搜索引擎
小宋10213 天前
AI 爬虫把大学图书馆站点拖垮:按行为指纹给爬虫分类、按类发配额、用边缘缓存分层,以带宽成本结构和真实用户 P95 延迟定档
人工智能·爬虫·分类
wuyk5554 天前
Spider-第10讲-SQLite持久化与去重
数据库·爬虫·sqlite
wuyk5554 天前
Spider-第09讲-三格式落盘CSV-Excel-JSON
爬虫·python·json·excel
wuyk5555 天前
Spider-第07讲-JSON接口与正则提取
爬虫·python·json
feasibility.5 天前
一物降一物?AI逆向没有终局:REA拆App,BLA设套,LASIK清场
人工智能·爬虫·github·逆向·skill·rea
wuyk5557 天前
Spider-第03讲-HTTP速通与读懂响应
网络·爬虫·网络协议·http
xyzzklk13 天前
在Open-WebUI中提升向量化速度
网络·人工智能·爬虫·ai·语言模型·自然语言处理·安卓