nginx turns off the favicon.ico robots.txt logging configurations

  • 2020-05-06 12:18:42
  • OfStack

The nginx log recently had a large number of accesses to the 404 error log that favicon.ico could not find.


#  Put the following configuration in  server {}  block .
# Shut down favicon.ico Log when it does not exist 
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
#  Access to hidden files is not allowed for example  .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}


Related articles: