为Nginx日志添加bot过滤

Nginx的if实在是太难用了,条件里没法! && ||之类的。
想了一个土法子让Nginx支持多条件判断

set $isUser true;
if ( $http_referer = "www.17ce.com"){
    set $isUser false;
}
if ($http_user_agent ~*   "YoudaoBot|baiduspider|Googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|robozilla|msnbot|MJ12bot|NHN|Twiceler|ezooms|feedly|bot|spider|google|baidu|tencent"){
    set $isUser false;
}
if ($isUser = true){
    access_log  /home/wwwlogs/ruosen.io.log;
}

效果不错哈哈哈

Ruosen

Be a Geek, Do the right thing;