访问注销nginx不工作?

我有位于/etc/nginx/drop.conf中的以下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; } 

奇怪的是,当我把它包含在任何一个服务器指令中 – 即在我configuration的任何一个虚拟主机中 – 我仍然在我的访问日志中获得了favicon日志。 这是一个BUG? 它看起来像包括根本不工作?

虚拟主机的例子我在这包括:

 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; } 

但在访问日志的那个域名仍然看到:

 ***** - - [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" 

是的,我已经重新启动并重新加载nginx。

这实际上很有趣。 当我直接向上面的虚拟主机添加一个特定的位置指令,并禁用包括favicon.ico请求仍然被logging。 即。 我在下面的注释中join以下的虚拟主机:

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

很奇怪。

我会把早先的drop.conf放在conf(紧跟在root指令之后)。

还要确保重新加载或重新启动nginx,以便使用新的configuration。