nginx配置屏蔽蜘蛛访问
VPS技术分享
nginx配置屏蔽蜘蛛访问
2021-06-01 16:52
if ( $http_user_agent ~* "SemrushBot|semrush|petalsearch|PetalBot|dotbot|AhrefsBot|ahrefs|Googlebot" ) {
return 403 ;
}
#禁止Scrapy等爬虫工具的抓取
if ($http_user_agent ~* "Scrapy|Sogou web spider") {
return 403;
}
#禁止指定UA及UA为空的访问
if ($http_user_agent ~ "FeedDemon|SemrushBot|semrush|AhrefsBot|ahrefs|dotbot||Googlebot|JikeSpider|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|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|LinkpadBot|Ezooms|^$" )
{
return 403;
}