Skip to content

Can NPM Use the Lua Module? #5674

Description

@Astromormy

I learned you can actually configure nginx logging to include entire HTTP request/response bodies using third party modules. With that said, does NPM include the Lua module so you can use commands like lua_need_request_body

This is the excerpt I'm trying to add so my logs have full HTTP bodies in them

error_log /data/logs/verbose_error_logs debug;
access_log /data/logs/verbose_access_logs debug;
log_format verbose '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions