h5bp/server-configs

[nginx] Don't log commonly missing files

aitte opened this issue · 1 comments

This concludes my nginx issue submissions. ;-)

Here's a suggestion for a new config file addition. One that I use myself on all my sites:

dont-log-common-404.conf:

# Avoids filling up the error logs with commonly requested files.
# Note that if you have a custom 404 page, the request may be logged anyway.
location = /robots.txt { log_not_found off; }
location = /favicon.ico { log_not_found off; }
location = /apple-touch-icon.png { log_not_found off; }
location = /apple-touch-icon-precomposed.png { log_not_found off; }

Prevents the error.log file from filling up with missing robots.txt, favicon.ico, and apple iOS icon requests, and makes sure that it's actually filled with real stuff that matters, such as true errors.

Without this file, the error logs become unusable, since every client in the world requests at least one of these files, sometimes multiple, and most sites lack all or some of these non-critical files.

This and many other issues were fixed in the latest pull request.