Chinaunix首页 | 论坛 | 博客
  • 博客访问: 79954
  • 博文数量: 18
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 240
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-22 16:06
文章分类
文章存档

2014年(18)

我的朋友

分类: 网络与安全

2014-03-18 13:31:25

分析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;
   }
}
阅读(2911) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~