@@ -46,6 +46,8 @@ LUA_RESTYLRUCACHE_VER=${LUA_RESTYLRUCACHE_VER:-0.14}
4646NGINX_DEV_KIT=${NGINX_DEV_KIT:- 0.3.3}
4747HTTPREDIS_VER=${HTTPREDIS_VER:- 0.3.9}
4848NGXECHO_VER=${NGXECHO_VER:- 0.63}
49+ ZLIBNG_VER=${ZLIBNG_VER:- 2.2.4}
50+ PCRE2_VER=${PCRE2_VER:- 10.45}
4951# Define options
5052NGINX_OPTIONS=${NGINX_OPTIONS:- "
5153 --prefix=/etc/nginx \
@@ -60,19 +62,24 @@ NGINX_OPTIONS=${NGINX_OPTIONS:-"
6062 --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
6163 --user=nginx \
6264 --group=nginx \
65+ --with-cc-opt=-O2 \
6366 --with-cc-opt=-Wno-deprecated-declarations \
6467 --with-cc-opt=-Wno-ignored-qualifiers" }
6568# Define modules
6669NGINX_MODULES=${NGINX_MODULES:- " --with-threads \
6770 --with-file-aio \
71+ --with-poll_module \
72+ --with-select_module \
6873 --with-http_ssl_module \
6974 --with-http_v2_module \
7075 --with-http_mp4_module \
7176 --with-http_auth_request_module \
7277 --with-http_slice_module \
7378 --with-http_stub_status_module \
7479 --with-http_realip_module \
75- --with-http_sub_module" }
80+ --with-http_sub_module \
81+ --with-http_degradation_module \
82+ --with-http_secure_link_module" }
7683
7784# Define installation parameters for headless install (fallback if unspecifed)
7885if [[ $HEADLESS == " y" ]]; then
@@ -100,6 +107,9 @@ if [[ $HEADLESS == "y" ]]; then
100107 SRCACHE=${SRCACHE:- n}
101108 SETMISC=${SETMISC:- n}
102109 NGXECHO=${NGXECHO:- n}
110+ ZLIBNG=${ZLIBNG:- n}
111+ PCRE2=${PCRE2:- n}
112+ NGXWAF=${NGXWAF:- n}
103113 HPACK=${HPACK:- n}
104114 SSL=${SSL:- 1}
105115 RM_CONF=${RM_CONF:- y}
@@ -225,6 +235,15 @@ case $OPTION in
225235 while [[ $NGXECHO != " y" && $NGXECHO != " n" ]]; do
226236 read -rp " echo-nginx-module [y/n]: " -e -i n NGXECHO
227237 done
238+ while [[ $ZLIBNG != " y" && $ZLIBNG != " n" ]]; do
239+ read -rp " zlib-ng [y/n]: " -e -i n ZLIBNG
240+ done
241+ while [[ $PCRE2 != " y" && $PCRE2 != " n" ]]; do
242+ read -rp " pcre2 [y/n]: " -e -i n PCRE2
243+ done
244+ while [[ $NGXWAF != " y" && $NGXWAF != " n" ]]; do
245+ read -rp " ngx_waf [y/n]: " -e -i n NGXWAF
246+ done
228247
229248 if [[ $GEOIP = ' y' ]]; then
230249 # - Ask for a Maxmind user id and license key if headless=n
@@ -275,7 +294,13 @@ case $OPTION in
275294 apt-get install -y build-essential ca-certificates wget curl libpcre3 libpcre3-dev autoconf unzip automake libtool tar git libssl-dev zlib1g-dev uuid-dev lsb-release libxml2-dev libxslt1-dev cmake
276295
277296 if [[ $MODSEC == ' y' ]]; then
278- apt-get install -y apt-utils libcurl4-openssl-dev libgeoip-dev liblmdb-dev libpcre++-dev libyajl-dev pkgconf
297+ # https://github.com/owasp-modsecurity/ModSecurity/issues/2750
298+ wget http://ftp.de.debian.org/debian/pool/main/libp/libpcre++/libpcre++-dev_0.9.5-6.1+b11_amd64.deb
299+ wget http://ftp.de.debian.org/debian/pool/main/libp/libpcre++/libpcre++0v5_0.9.5-6.1+b11_amd64.deb
300+ apt install -y ./libpcre++0v5_0.9.5-6.1+b11_amd64.deb ./libpcre++-dev_0.9.5-6.1+b11_amd64.deb
301+ rm libpcre* .deb
302+
303+ apt-get install -y apt-utils libcurl4-openssl-dev libgeoip-dev liblmdb-dev libpcre++-dev libyajl-dev pkgconf libpcre2-dev pcre2-utils libmaxminddb-dev
279304 fi
280305
281306 if [[ $GEOIP == ' y' ]]; then
@@ -288,6 +313,10 @@ case $OPTION in
288313 apt-get install -y geoipupdate
289314 fi
290315
316+ if [[ $NGXWAF == ' y' ]]; then
317+ apt-get install -y flex bison python3
318+ fi
319+
291320 # PageSpeed
292321 if [[ $PAGESPEED == ' y' ]]; then
293322 cd /usr/local/src/nginx/modules || exit 1
@@ -504,6 +533,51 @@ case $OPTION in
504533 tar xaf v${NGXECHO_VER} .tar.gz
505534 fi
506535
536+ # Download zlib-ng
537+ if [[ $ZLIBNG == ' y' ]]; then
538+ cd /usr/local/src/nginx/modules || exit 1
539+ wget https://github.com/zlib-ng/zlib-ng/archive/refs/tags/${ZLIBNG_VER} .tar.gz
540+ tar xaf ${ZLIBNG_VER} .tar.gz
541+ cd zlib-ng-${ZLIBNG_VER} || exit 1
542+ ./configure
543+ make -j " $( nproc) "
544+ make test
545+ fi
546+
547+ # Download pcre2
548+ if [[ $PCRE2 == ' y' ]]; then
549+ cd /usr/local/src/nginx/modules || exit 1
550+ wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${PCRE2_VER} /pcre2-${PCRE2_VER} .tar.gz
551+ tar xaf pcre2-${PCRE2_VER} .tar.gz
552+ fi
553+
554+ # Download ngx_waf
555+ if [[ $NGXWAF == ' y' ]]; then
556+ cd /usr/local/src/nginx/modules || exit 1
557+ git clone --depth 1 -b master --single-branch https://github.com/ADD-SP/ngx_waf.git
558+ cd ngx_waf || exit 1
559+ make -j " $( nproc) "
560+ cd /usr/local/src/nginx/modules || exit 1
561+ git clone --depth 1 https://github.com/libinjection/libinjection.git
562+ cd libinjection || exit 1
563+ ./autogen.sh
564+ ./configure --prefix=/usr/local/libinjection
565+ make -j " $( nproc) "
566+ make install
567+ export LIB_INJECTION=/usr/local/libinjection
568+ cd /usr/local/src/nginx/modules || exit 1
569+ git clone --depth 1 --branch stable https://github.com/jedisct1/libsodium.git
570+ cd libsodium || exit 1
571+ ./configure --prefix=/usr/local/libsodium --with-pic
572+ make -j$( nproc)
573+ make check -j $( nproc)
574+ make install
575+ export LIB_SODIUM=/usr/local/libsodium
576+ cd /usr/local/src/nginx/modules || exit 1
577+ git clone --depth 1 https://github.com/troydhanson/uthash.git
578+ export LIB_UTHASH=/usr/local/src/nginx/modules/uthash
579+ fi
580+
507581 # Download and extract of Nginx source code
508582 cd /usr/local/src/nginx/ || exit 1
509583 wget -qO- http://nginx.org/download/nginx-${NGINX_VER} .tar.gz | tar zxf -
@@ -690,12 +764,45 @@ case $OPTION in
690764 )
691765 fi
692766
767+ if [[ $ZLIBNG == ' y' ]]; then
768+ NGINX_MODULES=$(
769+ echo " $NGINX_MODULES "
770+ echo --with-zlib=/usr/local/src/nginx/modules/zlib-ng-${ZLIBNG_VER}
771+ )
772+ fi
773+
774+ if [[ $PCRE2 == ' y' ]]; then
775+ NGINX_MODULES=$(
776+ echo " $NGINX_MODULES "
777+ echo --with-pcre=/usr/local/src/nginx/modules/pcre2-${PCRE2_VER}
778+ )
779+ fi
780+
781+ if [[ $NGXWAF == ' y' ]]; then
782+ NGINX_MODULES=$(
783+ echo " $NGINX_MODULES "
784+ echo --add-module=/usr/local/src/nginx/modules/ngx_waf
785+ )
786+ fi
787+
693788 # Cloudflare's TLS Dynamic Record Resizing patch
694789 if [[ $TLSDYN == ' y' ]]; then
695- wget https://raw.githubusercontent.com/nginx-modules/ngx_http_tls_dyn_size/master/nginx__dynamic_tls_records_1.17.7 %2B.patch -O tcp-tls.patch
790+ wget https://raw.githubusercontent.com/nginx-modules/ngx_http_tls_dyn_size/refs/heads/ master/nginx__dynamic_tls_records_1.27.5 %2B.patch -O tcp-tls.patch
696791 patch -p1 < tcp-tls.patch
697792 fi
698793
794+ # Use the OpenSSL library instead of the Nginx original function.
795+ if [[ $OPENSSL == ' y' ]]; then
796+ wget https://raw.githubusercontent.com/kn007/patch/refs/heads/master/use_openssl_md5_sha1.patch -O use_openssl_md5_sha1.patch
797+ patch -p1 < use_openssl_md5_sha1.patch
798+ fi
799+
800+ # use zlib-ng instead of zlib
801+ if [[ $ZLIBNG == ' y' ]]; then
802+ wget https://raw.githubusercontent.com/maximemichaud/nginx-autoinstall/refs/heads/master/patches/nginx_zlib-ng.patch -O nginx_zlib-ng.patch
803+ patch -p1 < nginx_zlib-ng.patch
804+ fi
805+
699806 # HTTP3
700807 if [[ $HTTP3 == ' y' ]]; then
701808 cd /usr/local/src/nginx/modules || exit 1
@@ -748,6 +855,11 @@ case $OPTION in
748855 fi
749856
750857 ./configure $NGINX_OPTIONS $NGINX_MODULES
858+
859+ if [[ $NGXWAF == ' y' ]]; then
860+ sed -i ' s/^\(CFLAGS.*\)/\1 -fstack-protector-strong -Wno-sign-compare/' objs/Makefile
861+ fi
862+
751863 make -j " $( nproc) "
752864 make install
753865
0 commit comments