自用Nginx拦截爬虫规则

2021-04-26  阅读 841 次

自用Nginx拦截爬虫规则,设置拦截规则。登录宝塔,点击网站--设置--伪静态 在里面添加下面代码即可。

if ($http_user_agent ~ semrush.com) {
  return  403 ;
}

if ($http_user_agent ~ www.semrush.com) {
  return  403 ;
}
if ($http_user_agent ~ webmaster.petalsearch.com) {
  return  403 ;
}
if ($http_user_agent ~ ahrefs.com) {
  return  403 ;
}

if ($http_user_agent ~ zhanzhang.toutiao.com) {
  return  403 ;
}

##或者下面的

if ($http_user_agent ~* "SemrushBot|PetalBot|AhrefsBot|Googlebot") { 
   return 403; 
}


本文地址:https://yaaibk.com/post/260.html
版权声明:本文为原创文章,版权归 本站 所有,欢迎分享本文,转载请保留出处!

评论已关闭!