I've got several sections in my Nginx config, fcgi for php, upstream for certain URLs etc and I want the nginx.log
file to no log anything for any query coming from localhost as internal processes just flood it and then get processed by cron scripts.
Any ideas?
I've tried this is it ignores it.
location / {
rewrites......
if ($host = 127.0.0.1){
access_log off;
}
}
Best Answer
Your config is correct, but NginX tends to be a little... crazy? with Ifs. Take a look on it's If is Evil wiki page.
Aside from that, instead of trying to disable the log on that condition, try to redirect it to another log, like
/var/log/nginx/access_localhost.log
and see if it helps (link it to/dev/null
if it works, or just truncate each day).Also remember that
access_log
diretives (and other directives in NginX) will not be inherited. This is a quote from the NginX mail list (linked from NginX's wiki) about the subject: