0

I have created a docker multi-stage build to be able to end up with a small, lean container with the most recent nginx version and some modules compiled from source.

At the end I copy over the binary and a few other files to the final container - this works fine.

Additionally I'm trying to set up modsecurity as instructed here: https://www.nginx.com/blog/compiling-and-installing-modsecurity-for-open-source-nginx/

This also works fine in the original build container. Bu when I copy over ngx_http_modsecurity_module.so to the final target container and launch nginx, it fails with:

[emerg] 1#1: dlopen() "/usr/local/nginx/modules/ngx_http_modsecurity_module.so" failed (libmodsecurity.so.3: cannot open shared object file: No such file or directory) in /etc/nginx/nginx.conf:10

The file definitely exists so the error message is neither very precise nor very helpful.

Since it works in the build container I suspect something else is missing but the error message does not give any helpful clues? What could be missing? Where could I look for further clues? Thanks.

PS: I start from debian:stretch-slim image

3 Answers 3

0

By coincidence I found it out now. I had to:

Also copy over:

/usr/local/modsecurity

and install:

libgeoip1 libxml2 liblmdb0 libyajl2

Probably because this is a dynamic module.

0

Try https://hub.docker.com/r/krish512/modsecurity/, it is already built with latest ModSecurity CRS rules

0

After checking this issue I got ModSecurity lib properly installed on Debian and globally available by adding this two flags to ./configure

--prefix=/usr --with-ld-opt=/usr/lib


Prior this, while checking ldd ngx_http_modsecurity_module.so I was getting

libmodsecurity.so.3 => /opt/ModSecurity/src/.libs/libmodsecurity.so.3

which was working fine until I cleaned build files. After removing /opt/ModSecurity dir ldd was returning

libmodsecurity.so.3 => not found

and openresty/nginx was failing with the same error message from the question.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .