访问注销nginx无法正常工作?

前端之家收集整理的这篇文章主要介绍了访问注销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;
}

奇怪的是,当我将它包含在任何服务器指令中时 – 即在我配置的任何虚拟主机中 – 我仍然在我的访问日志中获取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请求时,仍然会记录.即.我在include bit中注释并将以下内容添加到上面的虚拟主机:

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

很奇怪.

最佳答案
我会先把drop.conf放在conf中(就在root指令之后).

还要确保重新加载或重新启动Nginx,以便它使用新配置.

原文链接:https://www.f2er.com/nginx/435670.html

猜你在找的Nginx相关文章