Welcome! Log In Create A New Profile

Advanced

Capture full request/response body logging in nginx configured in reverse proxy mode reports nginx: [emerg] unknown directive "log_by_lua_block"

December 18, 2023 11:56AM
Hi,

I am running nginx version: nginx/1.24.0 as reverse proxy on CentOS Linux
release 7.9.2009 (Core). I have the below config
file /etc/nginx/conf.d/microservice.conf
I want to capture full request/response body logging in nginx.

# cat /etc/nginx/conf.d/microservice.conf
server {
listen 80;
server_name 192.168.0.129;

location / {
# Capture request headers and body
log_by_lua_block {
ngx.var.request_headers = ngx.req.raw_header()
ngx.var.request_body = ngx.req.get_body_data()
}

# Your regular location configuration here

# Capture response headers and body
body_filter_by_lua_block {
local resp_body = ngx.arg[1]
ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
if ngx.arg[2] then
ngx.var.resp_body = ngx.ctx.buffered
end
}
}
#nginx -t
*nginx: [emerg] unknown directive "log_by_lua_block" in*
/etc/nginx/conf.d/microservice.conf:8
nginx: configuration file /etc/nginx/nginx.conf test failed

Please guide me. Thanks in advance.

Best Regards,

Kaushal
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Capture full request/response body logging in nginx configured in reverse proxy mode reports nginx: [emerg] unknown directive "log_by_lua_block"

kaushalshriyan December 18, 2023 11:56AM

Re: Capture full request/response body logging in nginx configured in reverse proxy mode reports nginx: [emerg] unknown directive "log_by_lua_block"

Sergey A. Osokin December 18, 2023 12:50PM

Re: Capture full request/response body logging in nginx configured in reverse proxy mode reports nginx: [emerg] unknown directive "log_by_lua_block"

kaushalshriyan December 18, 2023 01:22PM

RE: Capture full request/response body logging in nginx configured in reverse proxy mode reports nginx: [emerg] unknown directive "log_by_lua_block"

Reinis Rozitis December 19, 2023 09:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 299
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready