目前除了我们常见的搜索引擎如百度、Google、Sogou、360等搜索引擎之外,还存在其他非常多的搜索引擎,通常这些搜索引擎不仅不会带来流量,因为大量的抓取请求,还会造成主机的CPU和带宽资源浪费,屏蔽方法也很简单,按照下面步骤操作即可,原理就是分析指定UA然后屏蔽。
首先进入宝塔面板,文件管理进入/www/server/nginx/conf目录,新建空白文件kill_bot.conf。然后将以下代码保存到当前文件中。
#禁止垃圾搜索引擎蜘蛛抓取
if ($http_user_agent ~* "CheckMarkNetwork|Synapse|Nimbostratus-Bot|Dark|scraper|LMAO|Hakai|Gemini|Wappalyzer|masscan|crawler4j|Mappy|Center|eright|aiohttp|MauiBot|Crawler|researchscan|Dispatch|AlphaBot|Census|ips-agent|NetcraftSurveyAgent|ToutiaoSpider|EasyHttp|Iframely|sysscan|fasthttp|muhstik|DeuSu|mstshash|HTTP_Request|ExtLinksBot|package|SafeDNSBot|CPython|SiteExplorer|SSH|MegaIndex|BUbiNG|CCBot|NetTrack|Digincore|aiHitBot|SurdotlyBot|null|SemrushBot|Test|Copied|ltx71|Nmap|DotBot|AdsBot|InetURL|Pcore-HTTP|PocketParser|Wotbox|newspaper|DnyzBot|redback|PiplBot|SMTBot|WinHTTP|Auto Spider 1.0|GrabNet|TurnitinBot|Go-Ahead-Got-It|Download Demon|Go!Zilla|GetWeb!|GetRight|libwww-perl|Cliqzbot|MailChimp|SMTBot|Dataprovider|XoviBot|linkdexbot|SeznamBot|Qwantify|spbot|evc-batch|zgrab|Go-http-client|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|EasouSpider|LinkpadBot|Ezooms") {
return 403;
break;
}
#禁止扫描工具客户端
if ($http_user_agent ~* "crawl|curb|git|Wtrace|Scrapy" ) {
return 403;
break;
}
保存后返回到宝塔 - 【网站】-【设置】点击左侧 【配置文件】选项卡,在 #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 上方空白行插入代码: include kill_bot.conf; 保存后即可生效,这样这些蜘蛛或工具扫描网站的时候就会提示403禁止访问。