leev / ngx_http_geoip2_module

Nginx GeoIP2 module
BSD 2-Clause "Simplified" License
983 stars 186 forks source link

ngx_http_geoip2_module.so" version 1022001 instead of 1024000 #130

Closed encryptblockr closed 2 months ago

encryptblockr commented 2 months ago

I am getting this error when trying to use geoip2

/docker-entrypoint.sh: Configuration complete; ready for start up
2024/09/21 17:37:57 [emerg] 1#1: module "/etc/nginx/modules/ngx_http_geoip2_module.so" version 1022001 instead of 1024000 in /etc/nginx/nginx.conf:1
nginx: [emerg] module "/etc/nginx/modules/ngx_http_geoip2_module.so" version 1022001 instead of 1024000 in /etc/nginx/nginx.conf:1

all i did is install the module in alpine and then load the module in nginx config

apk --no-cache add nginx-mod-http-geoip2

and then in nginx.conf file

load_module modules/ngx_http_geoip2_module.so;

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # geoip_country /usr/share/GeoIP/GeoLite2-City.mmdb;
    # geoip_city    /usr/share/GeoIP/GeoLite2-City.mmdb;
    geoip2 /usr/share/GeoIP/GeoLite2-City.mmdb;

    log_format json_analytics escape=json '{'
      '"time_local": "$time_local", '
      '"remote_addr": "$remote_addr", '
      '"request_uri": "$request_uri", '
      '"status": "$status", '
      '"http_referer": "$http_referer", '
      '"http_user_agent": "$http_user_agent", '
    #   '"server_name": "$server_name", '
    #   '"request_time": "$request_time", '
      '"geoip2_city_country_name": "$geoip_city_country_name", '
      '"geoip2_country_name": "$http_cf_connecting_name", '
      '"geoip2_country_code": "$http_cf_connecting_ip"'
    '}';

    access_log /var/log/nginx/analytics.log json_analytics;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 30;

    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_min_length 256;

    include /etc/nginx/conf.d/*.conf;
}

when i check the container i see

/ # apk --no-cache add nginx-mod-http-geoip2
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
(1/2) Installing libmaxminddb-libs (1.7.1-r0)
(2/2) Installing nginx-mod-http-geoip2 (1.22.1-r1)
OK: 44 MiB in 64 packages

/ # ls -lha /usr/lib/nginx/modules
total 4M     
drwxr-xr-x    1 root     root        4.0K Sep 21 12:38 .
drwxr-xr-x    1 root     root        4.0K Oct 21  2023 ..
-rw-r--r--    1 root     root          49 Oct 15  2023 10_http_geoip2.conf
-rwxr-xr-x    1 root     root       18.2K Oct 15  2023 ngx_http_geoip2_module.so
-rwxr-xr-x    1 root     root       19.6K Apr 11  2023 ngx_http_geoip_module-debug.so
-rwxr-xr-x    1 root     root       19.6K Apr 11  2023 ngx_http_geoip_module.so
-rwxr-xr-x    1 root     root       26.8K Apr 11  2023 ngx_http_image_filter_module-debug.so
-rwxr-xr-x    1 root     root       22.8K Apr 11  2023 ngx_http_image_filter_module.so
-rwxr-xr-x    1 root     root      854.8K Apr 11  2023 ngx_http_js_module-debug.so
-rwxr-xr-x    1 root     root      850.7K Apr 11  2023 ngx_http_js_module.so
-rwxr-xr-x    1 root     root       22.8K Apr 11  2023 ngx_http_xslt_filter_module-debug.so
-rwxr-xr-x    1 root     root       22.8K Apr 11  2023 ngx_http_xslt_filter_module.so
-rwxr-xr-x    1 root     root       19.2K Apr 11  2023 ngx_stream_geoip_module-debug.so
-rwxr-xr-x    1 root     root       19.2K Apr 11  2023 ngx_stream_geoip_module.so
-rwxr-xr-x    1 root     root      833.3K Apr 11  2023 ngx_stream_js_module-debug.so
-rwxr-xr-x    1 root     root      833.2K Apr 11  2023 ngx_stream_js_module.so

/ # cat /usr/lib/nginx/modules/10_http_geoip2.conf 
load_module "modules/ngx_http_geoip2_module.so";

so what is going on why am i getting the error

/docker-entrypoint.sh: Configuration complete; ready for start up
2024/09/21 17:40:15 [emerg] 1#1: module "/etc/nginx/modules/ngx_http_geoip2_module.so" version 1022001 instead of 1024000 in /etc/nginx/nginx.conf:1
nginx: [emerg] module "/etc/nginx/modules/ngx_http_geoip2_module.so" version 1022001 instead of 1024000 in /etc/nginx/nginx.conf:1
encryptblockr commented 2 months ago

I was able to fix this by building new nginx image and compiling the module with custom image

it is unfortunate that downloading the module is not as simple as just adding the package