我想在 nginx 访问日志中包含 cookie 数据,如下所示:
(简化示例)
log_format foo '$remote_addr "$request" $cookie_bar';
access_log /var/log/nginx/access.log foo;
Run Code Online (Sandbox Code Playgroud)
这对于已经有 cookie“bar”的请求非常有效,但是对于我的服务器的第一个请求,nginx 会将“-”报告为“bar”的值。
我的问题似乎是 nginx 正在查看请求标头中的 cookie 值。有没有办法检查响应中的 Set-Cookie 并将其用作后备?