泰山神 发表于 2018-11-13 10:22:46

nginx 日志过滤网络爬虫

  分析nginx日志的时候,比较头疼的是有许多蜘蛛爬虫的痕迹。
  鉴于多数蜘蛛爬虫都是叫xx-bot或者xx-spider,下面的方法可以给爬虫单独写日志:
location / {  if ($http_user_agent ~* "bot|spider") {
  access_log      /var/log/nginx/spider.access.log;
  }
  
}
  或者干脆不写日志
location / {  if ($http_user_agent ~* "bot|spider") {
  access_log off;
  }
  
}


页: [1]
查看完整版本: nginx 日志过滤网络爬虫