Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Ive 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?

Ive tried this is it ignores it.

location / {
   rewrites......
   if ($host = 127.0.0.1){
     access_log off;
   }
}
share|improve this question

1 Answer 1

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:

There is no "global" logs in nginx, only "local" ones, either explicitly defined or inhereted from previous level.

The access_log directive, as all array-type directives in nginx config, will ignore inherited values if defined at certain level. I.e. in configuration

http { access_log log1;

server {
    server_name  server1;
}

server {
    server_name  server2;
    access_log   log2;
    ...
} }

only server1 will have logging set to log1, while server2 will have logging set to log2. If you want server2 to write log into both log1 and log2 you should say this explicitly, i.e.

server {
    server_name  server2;
    access_log   log1;
    access_log   log2;
    ...
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.