Building NGINX with ngx_http_geoip2_module in Docker causing error: version 1023001 instead of 1025002 ... reddit / selfhosted ---------------------------------------------------------------------- Ok-Flow-3732 · 2023-10-12 01:58 I got problem with building running NGINX with ngx_http_geoip2_module, after building it with docker I get an error: `module "/usr/local/nginx/modules/ngx_http_geoip2_module.so" version 1023001 instead of 1025002 in /etc/nginx/nginx.conf:6` These are my building commands I use in gitlab, just in case I remove existing image to avoid caching, meaning I'm rebuilding everything each time. But the error still persist. ``` - docker rmi --force $IMG:latest - docker build --tag $IMG:$CI_COMMIT_SHA --tag $IMG:latest --build-arg BUILDKIT_INLINE_CACHE=1 --no-cache -f ./reverse-proxy/nginx/Dockerfile.nginx ./reverse-proxy/nginx/ ``` My docker file: ``` FROM nginx:alpine3.18 AS builder LABEL SPDX-License-Identifier="AGPL-3.0-or-later" ENV NAXSI_VERSION=1.3 ENV NGINX_VERSION=1.23.1 RUN apk add --no-cache --virtual .build-deps \ gcc \ geoip-dev \ git \ libc-dev \ libmaxminddb \ libmaxminddb-dev \ make \ openssl-dev \ pcre-dev \ python3-dev \ py3-pip \ zlib-dev WORKDIR /usr/local RUN git clone https://github.com/leev/ngx_http_geoip2_module.git --depth=1 RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \ mkdir -p /usr/src && \ tar -zxC /usr/src -f nginx-${NGINX_VERSION}.tar.gz # COPY naxsi-${NAXSI_VERSION} /usr/src/naxsi-${NAXSI_VERSION} RUN CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p') \ cd /usr/src/nginx-$NGINX_VERSION && \ ./configure --with-compat $CONFARGS \ # --add-dynamic-module=/usr/src/naxsi-${NAXSI_VERSION}/naxsi_src/ \ --add-dynamic-module=/usr/local/ngx_http_geoip2_module/ && \ make && \ make modules && \ make install && \ mkdir -p /usr/local/nginx/modules/ # mkdir -p /usr/local/nginx/modules/ && \ # cp objs/ngx_http_naxsi_module.so /usr/local/nginx/modules/ngx_http_naxsi_module.so # RUN cd /usr/src/naxsi-${NAXSI_VERSION} && \ # pip install --upgrade pip && \ # cp naxsi_config/naxsi_core.rules /etc/nginx/ && \ # cd nxapi && \ # pip install -r requirements.txt && \ # python3 setup.py install FROM nginx:alpine3.18 LABEL SPDX-License-Identifier="AGPL-3.0-or-later" # ARG DOMAIN_NAME_ARG COPY ./GeoLite2-Country.mmdb /usr/share/geoip/ COPY ./GeoLite2-City.mmdb /usr/share/geoip/ RUN chmod -R +x /usr/share/geoip # COPY --from=builder /usr/local/nginx/modules/ngx_http_naxsi_module.so /usr/local/nginx/modules/ngx_http_naxsi_module.so COPY --from=builder /usr/local/nginx/modules/ngx_http_geoip2_module.so /usr/local/nginx/modules/ngx_http_geoip2_module.so # COPY --from=builder /etc/nginx/naxsi_core.rules /etc/nginx/naxsi_core.rules RUN apk add \ libmaxminddb \ libmaxminddb-dev COPY ./nginx.conf /etc/nginx/ # COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf # RUN sed -i "s/\${DOMAIN_NAME}/$DOMAIN_NAME_ARG/g" /etc/nginx/conf.d/default.conf # COPY ./build/. /usr/share/nginx/html # RUN chmod -R +x /usr/share/nginx/html RUN ln -sf /dev/stdout /var/log/nginx/main.access.log RUN ln -sf /dev/stdout /var/log/nginx/main.error.log ``` ---------------------------------------------------------------------- thekrautboy · 2023-10-12 02:31 /r/Docker? ---------------------------------------------------------------------- NikStalwart · 2023-10-12 04:40 Your formatting is rather mangled  — to use code formatting on reddit, start each line with four spaces, or, maybe better, upload to a gist/pastebin site for easier readability. Do you get any errors during the build process? Do your nginx and module versions match? From cursory inspection, I think it is seeing some sort of version mismatch. ---------------------------------------------------------------------- ElevenNotes · 2023-10-12 05:11 [Here](https://github.com/11notes/docker- nginx/blob/master/amd64.dockerfile) maybe my build file will help you a little, yours is a little messy.