owasp-modsecurity / ModSecurity-nginx

ModSecurity v3 Nginx Connector
Apache License 2.0
1.59k stars 282 forks source link

liblmdb and libmaxminddb not found #209

Closed RazaGR closed 4 years ago

RazaGR commented 4 years ago

I am trying to build a docker image based on Debian for nginx, build is successful but when I test ngx_http_modsecurity_module.so, it returns liblmdb and libmaxminddb not found?

Thanks for any support

1. compile ModSecurity

    MODSEC_BRANCH=v3.0.4
    git clone -b ${MODSEC_BRANCH} --depth 1 https://github.com/SpiderLabs/ModSecurity && \
    git -C /opt/ModSecurity submodule update --init --recursive && \
    (cd "/opt/ModSecurity" && \
        ./build.sh && \
        ./configure --with-lmdb --with-maxmind && \
        make && \
        make install \
    ) && \
    rm -fr /opt/ModSecurity \
        /usr/local/modsecurity/lib/libmodsecurity.a \
        /usr/local/modsecurity/lib/libmodsecurity.la

2. compile nginx

NGINX_VERSION_BUILD=`nginx -v 2>&1` && NGINX_VERSION_BUILD=${NGINX_VERSION_BUILD#*nginx/} \
    && DEBIAN_VERSION="$(cat /etc/os-release | grep CODENAME | cut -f2 -d '=')" \
    && echo "deb-src http://nginx.org/packages/mainline/debian/ $DEBIAN_VERSION nginx" >> /etc/apt/sources.list \
    && apt-get update \
    && apt-get build-dep -y nginx=${NGINX_VERSION_BUILD} \
    && wget -O nginx-release-${NGINX_VERSION_BUILD}.tar.gz https://github.com/nginx/nginx/archive/release-${NGINX_VERSION_BUILD}.tar.gz \
    && tar zxf nginx-release-${NGINX_VERSION_BUILD}.tar.gz \
    && cd nginx-release-${NGINX_VERSION_BUILD} \
    && auto/configure \
    --with-compat \
    --add-dynamic-module=/opt/ModSecurity-nginx \
    --add-dynamic-module=/opt/ngx_http_geoip2_module \
    --with-debug \
    && make modules \
    && cp ./objs/ngx_http_modsecurity_module.so \
        ./objs/ngx_http_geoip2_module.so \
        /usr/lib/nginx/modules/ \
    && rm -fr /opt/*

3. testing returns liblmdb and libmaxminddb not found ldd /etc/nginx/modules/ngx_http_modsecurity_module.so

    linux-vdso.so.1 (0x00007ffe86992000)
    libmodsecurity.so.3 => /usr/local/modsecurity/lib/libmodsecurity.so.3 (0x00007f062e3ae000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f062e1ea000)
    libcurl.so.4 => /usr/lib/x86_64-linux-gnu/libcurl.so.4 (0x00007f062e159000)
    libGeoIP.so.1 => /usr/lib/x86_64-linux-gnu/libGeoIP.so.1 (0x00007f062df24000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f062df1a000)
    libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f062dd71000)
    liblmdb.so.0 => not found
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f062dcfb000)
    libmaxminddb.so.0 => not found
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f062db77000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f062d9f4000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f062e5ef000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f062d9da000)
    libnghttp2.so.14 => /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f062d9b0000)
    libidn2.so.0 => /usr/lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f062d991000)
    librtmp.so.1 => /usr/lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f062d774000)
    libssh2.so.1 => /usr/lib/x86_64-linux-gnu/libssh2.so.1 (0x00007f062d746000)
    libpsl.so.5 => /usr/lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f062d733000)
    libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f062d6a1000)
    libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f062d3b6000)
    libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f062d369000)
    libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f062d289000)
    libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f062d255000)
    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f062d24f000)
    libldap_r-2.4.so.2 => /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f062d1fb000)
    liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f062d1e8000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f062cfca000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f062cfa9000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f062cfa4000)
    libicui18n.so.63 => /usr/lib/x86_64-linux-gnu/libicui18n.so.63 (0x00007f062ccc9000)
    libicuuc.so.63 => /usr/lib/x86_64-linux-gnu/libicuuc.so.63 (0x00007f062cafa000)
    libicudata.so.63 => /usr/lib/x86_64-linux-gnu/libicudata.so.63 (0x00007f062b108000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f062b0e0000)
    libunistring.so.2 => /usr/lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f062af5c000)
    libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f062adb0000)
    libhogweed.so.4 => /usr/lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007f062ad77000)
    libnettle.so.6 => /usr/lib/x86_64-linux-gnu/libnettle.so.6 (0x00007f062ad3d000)
    libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f062acba000)
    libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f062ab9c000)
    libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f062ab8d000)
    libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f062ab86000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f062ab6c000)
    libsasl2.so.2 => /usr/lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f062ab4d000)
    libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f062aa1e000)
    libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f062a80b000)
    libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f062a7e8000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f062a7dc000)
RazaGR commented 4 years ago

ah I had to install packages in final step of my DockerFile

apt-get install --no-install-recommends --no-install-suggests -y \
    liblmdb-dev \
    libmaxminddb-dev