this post was submitted on 12 Sep 2024
1 points (100.0% liked)

nginx

4 readers
1 users here now

The nginx community on Reddit. Reddit gives you the best of the internet in one place.

founded 1 year ago
MODERATORS
 
The original post: /r/nginx by /u/Yakuwari on 2024-09-12 17:45:24.

I'm trying to divide my logs between obvious bots and the rest. I use these maps:

map $http_user_agent $is_bot {
    default 0;  # 0 means non-bot
    "~*bot" 1;  # 1 means bot
    "~*crawl" 1;
    "~*spider" 1;
    "~*slurp" 1;
    "~*googleother" 1;
}
map $http_user_agent $is_not_bot {
    default 1;  # 1 means non-bot
    "~*bot" 0;  # 0 means bot
    "~*crawl" 0;
    "~*spider" 0;
    "~*slurp" 0;
    "~*googleother" 0;
}
access_log /var/log/nginx/access_non_bots.log combined if=$is_not_bot;
access_log /var/log/nginx/access_bots.log combined if=$is_bot;

Is there any easier way to do this?

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here