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

Kaushal Shriyan kaushalshriyan at gmail.com
Mon Dec 18 18:21:13 UTC 2023


On Mon, Dec 18, 2023 at 11:19 PM Sergey A. Osokin <osa at freebsd.org.ru>
wrote:

> Hi Kaushal,
>
> On Mon, Dec 18, 2023 at 10:24:14PM +0530, Kaushal Shriyan wrote:
> >
> > 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.
>
> Since you question is related to a third-party module, I'd recommend
> to get support in a appropriate mailing list.
>
>
Thanks Sergey for the quick response. Is there a way to capture full
request/response body logging in nginx without Lua module support? Please
ignore the earlier OS version, CentOS Linux release 7.9.2009 (Core).

#cat /etc/redhat-release
Red Hat Enterprise Linux release 8.8 (Ootpa)
# nginx -V
nginx version: nginx/1.24.0
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
built with OpenSSL 1.1.1k  FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
--modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx
--with-compat --with-file-aio --with-threads --with-http_addition_module
--with-http_auth_request_module --with-http_dav_module
--with-http_flv_module --with-http_gunzip_module
--with-http_gzip_static_module --with-http_mp4_module
--with-http_random_index_module --with-http_realip_module
--with-http_secure_link_module --with-http_slice_module
--with-http_ssl_module --with-http_stub_status_module
--with-http_sub_module --with-http_v2_module --with-mail
--with-mail_ssl_module --with-stream --with-stream_realip_module
--with-stream_ssl_module --with-stream_ssl_preread_module
--with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
-fstack-protector-strong -grecord-gcc-switches
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
-fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

# rpm -qa | grep nginx
nginx-1.24.0-1.el8.ngx.x86_64
#nginx -v
nginx version: nginx/1.24.0
#

# yum search nginx
Updating Subscription Management repositories.
Last metadata expiration check: 3:07:49 ago on Mon 18 Dec 2023 08:40:51 PM
IST.
================================================================ Name
Exactly Matched: nginx
=================================================================
nginx.x86_64 : High performance web server
=============================================================== Name &
Summary Matched: nginx
================================================================
collectd-nginx.x86_64 : Nginx plugin for collectd
lemonldap-ng-nginx.noarch : LemonLDAP-NG Nginx support
munin-nginx.noarch : NGINX support for Munin resource monitoring
nginx-all-modules.noarch : A meta package that installs all available Nginx
modules
nginx-debuginfo.x86_64 : Debug information for package nginx
nginx-filesystem.noarch : The basic directory layout for the Nginx server
nginx-mod-http-image-filter.x86_64 : Nginx HTTP image filter module
nginx-mod-http-perl.x86_64 : Nginx HTTP perl module
nginx-mod-http-xslt-filter.x86_64 : Nginx XSLT module
nginx-mod-mail.x86_64 : Nginx mail modules
nginx-mod-stream.x86_64 : Nginx stream modules
nginx-module-image-filter.x86_64 : nginx image filter dynamic module
nginx-module-image-filter-debuginfo.x86_64 : Debug information for package
nginx-module-image-filter
nginx-module-njs.x86_64 : nginx njs dynamic modules
nginx-module-njs-debuginfo.x86_64 : Debug information for package
nginx-module-njs
nginx-module-perl.x86_64 : nginx Perl dynamic module
nginx-module-perl-debuginfo.x86_64 : Debug information for package
nginx-module-perl
nginx-module-xslt.x86_64 : nginx xslt dynamic module
nginx-module-xslt-debuginfo.x86_64 : Debug information for package
nginx-module-xslt
pagure-web-nginx.noarch : Nginx configuration for Pagure
pcp-pmda-nginx.x86_64 : Performance Co-Pilot (PCP) metrics for the Nginx
Webserver
python3-certbot-nginx.noarch : The nginx plugin for certbot
sympa-nginx.x86_64 : Sympa with nginx
# yum -y install nginx-all-modules.noarch
Updating Subscription Management repositories.
Last metadata expiration check: 3:08:26 ago on Mon 18 Dec 2023 08:40:51 PM
IST.
Dependencies resolved.
==============================================================================================================================================================
 Package                               Architecture     Version
                                 Repository
 Size
==============================================================================================================================================================
Installing:
 nginx-all-modules                     noarch
1:1.14.1-9.module+el8.0.0+4108+af250afe
 rhel-8-for-x86_64-appstream-rpms            24 k
Installing dependencies:
 nginx-mod-http-image-filter           x86_64
1:1.14.1-9.module+el8.0.0+4108+af250afe
 rhel-8-for-x86_64-appstream-rpms            35 k
 nginx-mod-http-perl                   x86_64
1:1.14.1-9.module+el8.0.0+4108+af250afe
 rhel-8-for-x86_64-appstream-rpms            46 k
 nginx-mod-http-xslt-filter            x86_64
1:1.14.1-9.module+el8.0.0+4108+af250afe
 rhel-8-for-x86_64-appstream-rpms            34 k
 nginx-mod-mail                        x86_64
1:1.14.1-9.module+el8.0.0+4108+af250afe
 rhel-8-for-x86_64-appstream-rpms            64 k
 nginx-mod-stream                      x86_64
1:1.14.1-9.module+el8.0.0+4108+af250afe
 rhel-8-for-x86_64-appstream-rpms            85 k
Enabling module streams:
 nginx                                                  1.14

Transaction Summary
==============================================================================================================================================================
Install  6 Packages

Total download size: 287 k
Installed size: 399 k
Downloading Packages:
(1/6): nginx-all-modules-1.14.1-9.module+el8.0.0+4108+af250afe.noarch.rpm
                                                   10 kB/s |  24 kB
00:02
(2/6):
nginx-mod-http-image-filter-1.14.1-9.module+el8.0.0+4108+af250afe.x86_64.rpm
                                           15 kB/s |  35 kB     00:02
(3/6): nginx-mod-http-perl-1.14.1-9.module+el8.0.0+4108+af250afe.x86_64.rpm
                                                   20 kB/s |  46 kB
00:02
(4/6):
nginx-mod-http-xslt-filter-1.14.1-9.module+el8.0.0+4108+af250afe.x86_64.rpm
                                            17 kB/s |  34 kB     00:02
(5/6): nginx-mod-mail-1.14.1-9.module+el8.0.0+4108+af250afe.x86_64.rpm
                                                    32 kB/s |  64 kB
00:02
(6/6): nginx-mod-stream-1.14.1-9.module+el8.0.0+4108+af250afe.x86_64.rpm
                                                    43 kB/s |  85 kB
00:02
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Total
                                                   67 kB/s | 287 kB
00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :

   1/1
  Installing       :
nginx-mod-stream-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         1/6
  Running scriptlet:
nginx-mod-stream-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         1/6
  Installing       :
nginx-mod-mail-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         2/6
  Running scriptlet:
nginx-mod-mail-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         2/6
  Installing       :
nginx-mod-http-xslt-filter-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         3/6
  Running scriptlet:
nginx-mod-http-xslt-filter-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         3/6
  Installing       :
nginx-mod-http-perl-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                          4/6
  Running scriptlet:
nginx-mod-http-perl-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                          4/6
  Installing       :
nginx-mod-http-image-filter-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                          5/6
  Running scriptlet:
nginx-mod-http-image-filter-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                          5/6
  Installing       :
nginx-all-modules-1:1.14.1-9.module+el8.0.0+4108+af250afe.noarch
                                                          6/6
  Running scriptlet:
nginx-all-modules-1:1.14.1-9.module+el8.0.0+4108+af250afe.noarch
                                                          6/6
  Verifying        :
nginx-all-modules-1:1.14.1-9.module+el8.0.0+4108+af250afe.noarch
                                                          1/6
  Verifying        :
nginx-mod-http-image-filter-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                          2/6
  Verifying        :
nginx-mod-http-perl-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                          3/6
  Verifying        :
nginx-mod-http-xslt-filter-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         4/6
  Verifying        :
nginx-mod-mail-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         5/6
  Verifying        :
nginx-mod-stream-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
                                                         6/6
Installed products updated.

Installed:
  nginx-all-modules-1:1.14.1-9.module+el8.0.0+4108+af250afe.noarch
 nginx-mod-http-image-filter-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
  nginx-mod-http-perl-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
 nginx-mod-http-xslt-filter-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
  nginx-mod-mail-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
nginx-mod-stream-1:1.14.1-9.module+el8.0.0+4108+af250afe.x86_64

Complete!

# 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20231218/9cef9778/attachment-0001.htm>


More information about the nginx mailing list