加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

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

发布时间:2020-12-13 21:39:42 所属栏目: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 IOlocation = /favicon.ico { access_log

我在/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,以便它使用新配置.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读