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里头验证登录之后设置

    原文作者:codecraft
    原文地址: https://segmentfault.com/a/1190000007947015
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞