使 nginx 日志忽略爬虫

map $http_user_agent $log_ua {

    ~Googlebot 0;
    ~Baiduspider 0;
    ~YandexBot 0;
    ~bingbot 0;
    ~MJ12bot 0;
    ~linkdexbot 0;
    ~GridBot 0;

    default 1;
}

server {
    access_log /var/log/nginx/blog.ihanai.access.log combined if=$log_ua;
}