nginx:为什么没有redect位置的访问日志

nginx:为什么没有redect位置的访问日志,nginx,logging,Nginx,Logging,我的nginx配置文件如下所示: server { location /mysite { auth_request /authVerify; proxy_pass http://localhost:4200; error_page 401 = /login; } location /authVerify { proxy_pass_request_body off; proxy

我的nginx配置文件如下所示:

server {        
    location /mysite {
        auth_request /authVerify;
        proxy_pass http://localhost:4200;
        error_page 401 = /login;
    }

    location /authVerify {
        proxy_pass_request_body off;
        proxy_set_header Content-Length "";
        proxy_set_header X-Original-URI $request_uri;
        proxy_pass http://localhost:3000;
    }

    location /login {
        proxy_cookie_path / "/; HttpOnly";
        proxy_pass http://localhost:3000;
    }

    location / {
        root   html;
        index  index.html index.htm;
    }
}
与日志相关的配置使用默认设置

auth\u请求
configuration起作用。但是当我向
/mysite
发送请求时,访问日志中只记录了该请求,而没有记录
/authVerify
,尽管它实际上是通过此位置代理的。如果我直接向
/authVerify
发送请求,也会有日志记录

那么,在重定向情况下,如何为请求所经过的所有位置生成日志呢

更新 根据注释,我在
http
块级别将
log\u子请求设置为on。更改后,生成了internal Redict的日志,但原始
mysite
位置的日志消失

当前,在我向
/mysite
发送一个请求后,日志如下所示:

server {        
    location /mysite {
        auth_request /authVerify;
        proxy_pass http://localhost:4200;
        error_page 401 = /login;
    }

    location /authVerify {
        proxy_pass_request_body off;
        proxy_set_header Content-Length "";
        proxy_set_header X-Original-URI $request_uri;
        proxy_pass http://localhost:3000;
    }

    location /login {
        proxy_cookie_path / "/; HttpOnly";
        proxy_pass http://localhost:3000;
    }

    location / {
        root   html;
        index  index.html index.htm;
    }
}

我在nginx doc上找到了以下解释:

请求记录在处理结束位置的上下文中。如果在请求处理过程中发生内部重定向,则它可能与原始位置不同。


是因为这个吗?还有其他方法记录请求的整个流程吗

您是否尝试过启用日志子请求

log_subrequest

Context: http, server, and location

Enables or disables logging of sub-requests triggered by internal redirects or SSI requests.

Syntax: on or off

Default value: off

多谢各位
log\u子请求
可以记录重定向位置。但原始位置的日志将不会输出。请在帖子中查看我的更新。需要更多的调整。这是因为日志只在最终处理上下文中显示,即最后一个子请求。您可以将一些X头添加到子请求并检索它以写入日志或使用一些现有的预定义变量: