#放在http{}里面
    log_format  kyh  ' [$time_local] "$request" $status \n'
        'req_header:"$req_header" \n req_body:"$request_body" \n'
        'resp_header:"$resp_header" \n  resp_body:"$resp_body"\n\n';


#以下loaction{}里的proxy_pass 语句下面
    #请求响应头部    
        set $req_header "";
        set $resp_header "";
        header_filter_by_lua '
            local h1 = ngx.req.get_headers()
            for k1, v1 in pairs(h1) do
            ngx.var.req_header=ngx.var.req_header..k1..": "..v1
            end
        
            local h = ngx.resp.get_headers()
            for k, v in pairs(h) do
            ngx.var.resp_header=ngx.var.resp_header..k..": "..v
            end
        ';
        
        
         lua_need_request_body on;
    #响应头部
        set $resp_body "";
        body_filter_by_lua '
            local resp_body = string.sub(ngx.arg[1], 1, 1000)
            ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
            if ngx.arg[2] then
                ngx.var.resp_body = ngx.ctx.buffered
            end
        ';