宝塔nginx屏蔽爬虫
今天服务器被爬的很惨,修服务器优化数据怎么都没用,发现是查询被疯狂调用,所以服务器mysqld服务器160%,查了下日志都是爬虫,其中Amazonbot/0.1,SemrushBo,dataforseobot,爬的最凶,虽然是好事,但是爬起来真要命,机子配置不好顶不住没办法,只好在nginx做屏蔽爬虫
代码如下,在宝塔软件商店,打开nginx,配置修改,server里头
server { listen 888; server_name phpmyadmin; index index.html index.htm index.php; root /www/server/phpmyadmin; location ~ /tmp/ { return 403; }
大概在这个地方
加入下面代码
#禁止Scrapy等工具的抓取 if ($http_user_agent ~* (Scrapy|Curl|HttpClient)) { return 403; } #禁止指定UA及UA为空的访问 if ($http_user_agent ~* (AhrefsBot|DataForSeoBot|DataForSeoBot/1.0|SemrushBot/7~bl|Amazonbot/0.1|SemrushBot/7|Amazonbot|SemrushBot|dataforseobot|dotbot|blexbot|wellknownbot|awariobot|phxbot|internet-measurement|gptbot|mj12bot|snapshot)) { return 403; }
可以有效屏蔽爬虫,服务器瞬间清爽了
上一篇:linux查看实时带宽占用
下一篇:宝塔开心版