Basically, I'm trying to remove search bots such as Google, Bing, and that are not from my access logs. They really grow over time, eventually adding hundreds of thousands of useless log access log entries, which is especially painful if you ever have to look for them. The problem I am facing is that I define an access log in my blocks, so Nginx just looks at it and ignores my second one, which I define in the location / block. If I comment out my access log for my site (and not the crawler block), then it works fine. Here is the configuration:
server { listen 80; server_name example.com; access_log /home/domains/example.com/logs/access; error_log /home/domains/example.com/logs/error; root /home/domains/example.com/forums; location / { index index.html index.htm; if ($http_user_agent ~* ("googlebot") ) { access_log off; } }
I deleted everything except this when posting (php include and what not), although I checked that nothing was stopping him by commenting on everything except the one above. Therefore, to summarize, I have a log defined in my virtual block to record all traffic (I defined it for each block in order to make it more accurate and what not). I am trying to turn off logging for specific user agents, if I do not turn off the main log for the site, it will continue to log what I am telling it not to user agents.
I have been on this for several hours, any help would be greatly appreciated.
nginx user-agent
Ryan
source share