wargio / naxsi

NAXSI is an open-source, high performance, low rules maintenance WAF for NGINX
GNU General Public License v3.0
274 stars 34 forks source link

[ppa:ondrej/nginx-mainline] nginx: configuration file /etc/nginx/nginx.conf test failed #30

Open nausixkiz opened 1 year ago

nausixkiz commented 1 year ago

Hello,

I'm using ppa:ondrej/nginx-mainline with version nginx/1.23.1. When I load the module ngx_http_naxsi_module.so into nginx.conf, I suddenly get an error below:

nginx: [emerg] dlopen() "/usr/share/nginx/modules/ngx_http_naxsi_module.so" failed (/usr/share/nginx/modules/ngx_http_naxsi_module.so: undefined symbol: pcre2_get_ovector_count_8) in /etc/nginx/nginx.conf:10
nginx: configuration file /etc/nginx/nginx.conf test failed

OS: Ubuntu 22.04 Nginx: nginx/1.23.1 Naxsi: wargio/naxsi on branch master

Can I know what's exactly wrong?

Thanks

UPDATE I built the module with Nginx from apt source nginx instead of downloading it from the Nginx homepage

wargio commented 1 year ago

looks like that you do not have a symbol. is the pcre version that you have built it for the same? also if you want there are builds for ubuntu here https://github.com/wargio/naxsi/actions/runs/3100186327 that is linked against the nginx from ubuntu

nausixkiz commented 1 year ago

Here is step I did

cd /usr/local/src
sudo apt source nginx # From deb-src https://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu/ jammy main
git clone --recurse-submodules https://github.com/wargio/naxsi.git

cd nginx-1.23.1 || exit
./configure --prefix=/etc/nginx --add-dynamic-module=/usr/local/src/naxsi/naxsi_src
make
sudo cp /usr/local/src/naxsi/naxsi_rules/naxsi_core.rules /etc/nginx/
sudo cp /usr/local/src/nginx-1.23.1/objs/ngx_http_naxsi_module.so /usr/lib/nginx/modules

Results:

checking for OS
 + Linux 5.15.0-48-generic x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 11.2.0 (Ubuntu 11.2.0-19ubuntu1) 
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... found
checking for eventfd() ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for UDP_SEGMENT ... found
checking for nobody group ... not found
checking for nogroup group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... found
checking for strerrordesc_np() ... found
checking for localtime_r() ... found
checking for clock_gettime(CLOCK_MONOTONIC) ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for ioctl(FIONREAD) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
configuring additional dynamic modules
adding module in /usr/local/src/naxsi/naxsi_src
 + naxsi was configured
checking for PCRE2 library ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE2 library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/etc/nginx"
  nginx binary file: "/etc/nginx/sbin/nginx"
  nginx modules path: "/etc/nginx/modules"
  nginx configuration prefix: "/etc/nginx/conf"
  nginx configuration file: "/etc/nginx/conf/nginx.conf"
  nginx pid file: "/etc/nginx/logs/nginx.pid"
  nginx error log file: "/etc/nginx/logs/error.log"
  nginx http access log file: "/etc/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

Result Makefile: https://anotepad.com/notes/ajsgk9y3

wargio commented 1 year ago

are you sure that you do not have a mismatch between libpcre2 and the libpcre2-dev?

nausixkiz commented 1 year ago

Can I get the clear meaning of "mismatch"? If you mean different versions then I tried rechecking libpcre2 , libpcre2-dev from apt and got a version match

apt list | grep "libpcre2"

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libpcre2-16-0/jammy,now 10.40-1+ubuntu22.04.1+deb.sury.org+1 amd64 [installed,automatic]
libpcre2-32-0/jammy,now 10.40-1+ubuntu22.04.1+deb.sury.org+1 amd64 [installed,automatic]
libpcre2-8-0/jammy,now 10.40-1+ubuntu22.04.1+deb.sury.org+1 amd64 [installed,automatic]
libpcre2-dev/jammy,now 10.40-1+ubuntu22.04.1+deb.sury.org+1 amd64 [installed]
libpcre2-posix3/jammy,now 10.40-1+ubuntu22.04.1+deb.sury.org+1 amd64 [installed,automatic]
wargio commented 1 year ago

hmm i have to check that ubuntu version. maybe they removed pcre2_get_ovector_count in the newest version. but that is kinda weird since you should have had an error due the missing function

wargio commented 1 year ago

can you try the build from the link above? the files are installed under:

/usr/lib/nginx/modules/ngx_http_naxsi_module.so
/data/usr/share/naxsi/naxsi_core.rules
nausixkiz commented 1 year ago

can you try the build from the link above? the files are installed under:

/usr/lib/nginx/modules/ngx_http_naxsi_module.so
/data/usr/share/naxsi/naxsi_core.rules

Let's me check it. I'll let you results if it available

nausixkiz commented 1 year ago

@wargio It passed when I built with Nginx Stable 1.22.0

deb http://nginx.org/packages/ubuntu/ jammy nginx
deb-src http://nginx.org/packages/ubuntu/ jammy nginx

It passed when I built with Nginx Mainline 1.23.1

deb https://nginx.org/packages/mainline/ubuntu jammy nginx
deb-src https://nginx.org/packages/mainline/ubuntu jammy nginx

It failed when I built with ondrej/nginx-mainline 1.23.1

deb https://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu/ jammy main
deb-src https://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu/ jammy main
wargio commented 1 year ago

ok, so maybe is a thing on 1.23.1 ?

nausixkiz commented 1 year ago

No, I found exactly problem. This error only occurs when I build from ondrej/nginx-mainline 1.23.1 instead of any Nginx packages. I have tested 3 case for this and the results mentioned above.

And, I still haven't found a solution to this problem

wargio commented 1 year ago

i have to ask, is there any reason why you want to use that specific ppa repository instead of just build your nginx bin ?

nausixkiz commented 1 year ago

Advantages

  1. Actively maintained
  2. Includes several main modules
  1. Reducing installation process, no compilation required.

That means, if I install the version directly from the Nginx homepage, I will have to manually install the all the above modules one by one.

wargio commented 1 year ago

ok, then maybe i should add this PPA into the pipeline