nginx的log_format记录header的字段

log_format

log_format  main  '$http_userId $http_userName $remote_addr $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for" $request_time';

通过http_argname来获取

设置header

ngx.req.set_header("userId",xxx)
ngx.req.set_header("userName",xxx)

在rewrite_by_lua_file里头验证登录之后设置

你可能感兴趣的:(nginx)