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.

I have the following drop.conf files located in /etc/nginx/drop.conf

# if you don't like seeing all the errors for missing favicon.ico requests
# sent by a lot of browsers in root we dont need to log these - they mean extra IO
location = /favicon.ico { access_log off; log_not_found off; }

# if you don't like seeing errors for a missing robots.txt in root
# same reason as above - extra IO
location = /robots.txt { allow all; access_log off; log_not_found off; }

location = /apple-touch-icon.png { access_log off; log_not_found off; }
location = /apple-touch-icon-precomposed.png { access_log off; log_not_found off; }

# this will prevent files like .htaccess .htpassword .secret .git .svn etc from being served
# You can remove the log directives if you wish to
# log any attempts at a client trying to access a hidden file
location ~ /\. { deny all; access_log off; log_not_found off; }

# Deny access to any files with a .php extension in the uploads directory
location ~* ^/wp-content/uploads/.*.php$ {
    deny all;
    access_log off;
    log_not_found off;
}

# Deny access to any files with a .php extension in the uploads directory for multisite
location ~* /files/(.*).php$ {
    deny all;
    access_log off;
    log_not_found off;
}

Strange thing is when I include it in whichever server directive - ie in whichever virtual host I have configured - I'm still getting favicon logs in my access log. Is this a BUG ?? It looks like the include is simply not working ?

Example of the virtual host I'm including this in:

server {
        listen       127.0.0.1:8080;
        server_name  .somehost.com;
    root  /var/www/somehost.com;

        access_log /var/log/nginx/somehost.com-access.nginx.log main;
    error_log  /var/log/nginx/somehost.com-error.nginx.log;

        location ~* \.php.$ {
        # Proxy all requests with an URI ending with .php*
        # (includes PHP, PHP3, PHP4, PHP5...)
        include /etc/nginx/fastcgi.conf;
        }

        # all other files
        location / {
            root  /var/www/somehost.com;
        }

        error_page 404 /errors/404.html;
        location /errors/ {
                alias /var/www/errors/;
                internal;
        }

        #this loads custom logging configuration which disables favicon error logging
        include /etc/nginx/drop.conf;
}

yet in access logs for that domain im still seeing:

***** - - [06/Jul/2012:22:16:05 +0000]  "GET /favicon.ico HTTP/1.1" 404 134 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11"

Yes I have restarted and reloaded nginx.

This is actually quite interesting. When I add a specific location directive directly to the virtual host above and disable the include favicon.ico requests ARE STILL being logged. ie. I comment in include bit and add the following to the above virtual host:

#include /etc/nginx/drop.conf;
location = /favicon.ico { access_log off; log_not_found off; }

Very strange.

share|improve this question
1  
Is it just favicon, or is robots.txt also being unexpectedly logged? –  cjc Jul 6 '12 at 23:52
    
apparently both are ignored but I guess it has something to do with that error_page directive.... –  gyre Jul 6 '12 at 23:59
1  
Yes, it does. You may wish to suppress logging for /errors/404.html too. –  sendmoreinfo Dec 22 '12 at 21:46
    
Did you get anywhere with this in the end? –  Drew Khoury Aug 18 '13 at 10:16

2 Answers 2

I would put the drop.conf earlier in the conf (just after the root directive).

Also make sure to reload or restart nginx so that it's using the new configuration.

share|improve this answer

You don't have favicon.ico or robots.txt in the root directory. nginx behaves properly and displays a 404 Not Found error (referencing to specified error_page for 404 reposnse).

Dirty hack:

touch /var/www/somehost.com/favicon.ico

touch /var/www/somehost.com/robots.txt

This will create zero-byte files but won't have any major effect on your I/O operations and nginx will deliver these files (all zero-bytes on both of them) and won't log it in your access/error log.

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.