Log_format record header field for nginx

  nginx

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';

Get via http_argname

Set header

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

Set after verifying login in rewrite_by_lua_file