[alibaba/tengine]编译时打开:--with-stream_geoip_module=dynamic无法加载

2024-07-12 353 views
9
编译时打开:--with-stream_geoip_module=dynamic
配置文件中加载:load_module "/usr/lib64/nginx/modules/ngx_stream_geoip_module.so";
# nginx -t 会无法通过,报错
nginx: [emerg] dlopen() "/usr/lib64/nginx/modules/ngx_stream_geoip_module.so" failed (/usr/lib64/nginx/modules/ngx_stream_geoip_module.so: undefined symbol: ngx_stream_add_variable) in /etc/nginx/nginx.conf:23
nginx: configuration file /etc/nginx/nginx.conf test failed

编译完整参数:

--prefix=/usr/share/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-openssl=/usr/local/src/openssl --with-openssl-opt=enable-tls1_3 --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_geoip_module=dynamic --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_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-stream_ssl_preread_module --with-stream_sni --with-jemalloc --with-pcre --with-pcre-jit --with-cc-opt='-O2 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=native' --with-ld-opt='-Wl,-z,relro -Wl,-E' --add-dynamic-module=./modules/ngx_http_concat_module --add-dynamic-module=./modules/ngx_http_footer_filter_module --add-dynamic-module=./modules/ngx_http_proxy_connect_module --add-dynamic-module=./modules/ngx_http_reqstat_module --add-dynamic-module=./modules/ngx_http_sysguard_module --add-dynamic-module=./modules/ngx_http_trim_filter_module --add-dynamic-module=./modules/ngx_http_upstream_check_module --add-dynamic-module=./modules/ngx_http_upstream_consistent_hash_module --add-dynamic-module=./modules/ngx_http_upstream_dynamic_module --add-dynamic-module=./modules/ngx_http_upstream_dyups_module --add-dynamic-module=./modules/ngx_http_upstream_session_sticky_module --add-dynamic-module=./modules/ngx_http_user_agent_module --add-dynamic-module=./modules/ngx_slab_stat --add-dynamic-module=./modules/ngx_http_lua_module --add-dynamic-module=/usr/local/src/ngx_devel_kit --add-dynamic-module=./modules/ngx_http_slice_module
  1. ./configure --prefix=/usr/share/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-openssl=/usr/local/src/openssl --with-openssl-opt='enable-tls1_3' --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_geoip_module=dynamic --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_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-stream_ssl_preread_module --with-stream_sni --with-jemalloc --with-pcre --with-pcre-jit --with-cc-opt='-O2 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=native' --with-ld-opt='-Wl,-z,relro -Wl,-E' --add-dynamic-module=./modules/ngx_http_concat_module --add-dynamic-module=./modules/ngx_http_footer_filter_module --add-dynamic-module=./modules/ngx_http_proxy_connect_module --add-dynamic-module=./modules/ngx_http_reqstat_module --add-dynamic-module=./modules/ngx_http_sysguard_module --add-dynamic-module=./modules/ngx_http_trim_filter_module --add-dynamic-module=./modules/ngx_http_upstream_check_module --add-dynamic-module=./modules/ngx_http_upstream_consistent_hash_module --add-dynamic-module=./modules/ngx_http_upstream_dynamic_module --add-dynamic-module=./modules/ngx_http_upstream_dyups_module --add-dynamic-module=./modules/ngx_http_upstream_session_sticky_module --add-dynamic-module=./modules/ngx_http_user_agent_module --add-dynamic-module=./modules/ngx_slab_stat --add-dynamic-module=./modules/ngx_http_lua_module --add-dynamic-module=/usr/local/src/ngx_devel_kit --add-dynamic-module=./modules/ngx_http_slice_module
  2. make install clean
  3. strip -g /usr/lib64/nginx/modules/*
  • Tengine version (use sbin/nginx -V):
# nginx -V
Tengine version: Tengine/2.3.1
nginx version: nginx/1.16.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.1.1b Tassl 0.2  26 Feb 2019
TLS SNI support enabled
configure arguments: --prefix=/usr/share/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-openssl=/usr/local/src/openssl --with-openssl-opt=enable-tls1_3 --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_geoip_module=dynamic --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_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-stream_ssl_preread_module --with-stream_sni --with-jemalloc --with-pcre --with-pcre-jit --with-cc-opt='-O2 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=native' --with-ld-opt='-Wl,-z,relro -Wl,-E' --add-dynamic-module=./modules/ngx_http_concat_module --add-dynamic-module=./modules/ngx_http_footer_filter_module --add-dynamic-module=./modules/ngx_http_proxy_connect_module --add-dynamic-module=./modules/ngx_http_reqstat_module --add-dynamic-module=./modules/ngx_http_sysguard_module --add-dynamic-module=./modules/ngx_http_trim_filter_module --add-dynamic-module=./modules/ngx_http_upstream_check_module --add-dynamic-module=./modules/ngx_http_upstream_consistent_hash_module --add-dynamic-module=./modules/ngx_http_upstream_dynamic_module --add-dynamic-module=./modules/ngx_http_upstream_dyups_module --add-dynamic-module=./modules/ngx_http_upstream_session_sticky_module --add-dynamic-module=./modules/ngx_http_user_agent_module --add-dynamic-module=./modules/ngx_slab_stat --add-dynamic-module=./modules/ngx_http_lua_module --add-dynamic-module=/usr/local/src/ngx_devel_kit --add-dynamic-module=./modules/ngx_http_slice_module 
  • OS (e.g. from /etc/os-release):
# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
  • Kernel (e.g. uname -a):
Linux izj6c5lasa7ruhz7ca937jz 3.10.0-693.5.2.tcpa06.tl2 #1 SMP Tue Jun 19 11:31:55 CST 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Others:

回答

9

@totemofwolf 请检查下load_module加载对应so的顺序,我猜测可能是由于load stream是在load geoip之后导致的。如果不是这个问题,请粘贴下配置文件内容。

3

是这样的。更改顺序后正常了,感谢康神(误

load_module "/usr/lib64/nginx/modules/ndk_http_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_concat_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_dyups_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_footer_filter_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_geoip_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_lua_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_reqstat_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_trim_filter_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_upstream_dynamic_module.so";
load_module "/usr/lib64/nginx/modules/ngx_http_user_agent_module.so";
#load_module "/usr/lib64/nginx/modules/ngx_stream_geoip_module.so";
load_module "/usr/lib64/nginx/modules/ngx_stream_module.so";
load_module "/usr/lib64/nginx/modules/ngx_stream_geoip_module.so";

#lua_package_path "/usr/local/share/luajit/jit/?.lua;;";
#lua_package_cpath "/usr/local/lib/?.so;;";
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful