即使 access_log 关闭,nginx 存根状态仍会记录

即使 access_log 关闭,nginx 存根状态仍会记录

我有一些东西从 stub_status 中提取数据,并且它堵塞了我的日志,即使我已在该位置关闭了日志......

nginx.conf:

...
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
...

我启用的网站:

upstream app_server_exmaple {
    server 127.0.0.1:8500 fail_timeout=0;
}

server {
    listen 80;
    #Listens for www. and redirects
    server_name www.exmaple.com;
    return 301 $scheme://exmaple.com$request_uri;
}

server {
    listen 80;
    #Listens for request on port 80 (http) and redirects them to https on port 443
    server_name exmaple.com;
    return 301 https://exmaple.com$request_uri;
}

server {
    listen 443 ssl;
    server_name exmaple.com;

    ssl_certificate /etc/letsencrypt/live/exmaple.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/exmaple.com/privkey.pem;

    client_max_body_size 4G;
    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/exmaple/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/exmaple/exmaple/static_dump; 
    }

    location /stub_status {
    stub_status;
    access_log off;
    # Set to machine IP because netdata request is coming from the machine IP
    allow my.ip.add.ress;
    deny all;
    }

    location ~ /.well-known {
        # Trying to serve LE auto-renew bot from here
    allow all;
        root /usr/share/nginx/html;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server_exmaple;
        #Uncomment the following line and comment the previous 4 and run nginx -s reload to enable maintenance
        #return 503;        
    }

   error_page 503 @maintenance;
   location @maintenance {
    rewrite ^(.*)$ /503.html break;
   }

   error_page 403 @forbidden;
   location @forbidden {
    rewrite ^(.*)$ /403.html break;
   }   
}

答案1

所以发生的情况是,它记录了前三个服务器块中的两个,其中重定向到 ssl 和非 www,但没有记录主服务器块。

解决方案是添加

access_log /dev/null;

到每一个街区,它就消失了

相关内容