Nginx 日志中记录cookie

时间:2020-12-18 01:31:04

在http节点下添加

log_format  mai2 '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$dm_cookie"';

在对应的server节点下添加

set $dm_cookie "";
if ($http_cookie ~* "(.+)(?:;|$)") {
set $dm_cookie $;
}

并将对应的log format改为 mai2

access_log logs/mobile-ssl.access.log mai2;