17 Commits
Author SHA1 Message Date
iamdoubz 56dca3e1c0 Update README to match freenginx version 2025-12-26 10:48:08 -06:00
iamdoubz 3d7e9701a1 Update freenginx, pcre, and header versions 2025-12-26 10:47:21 -06:00
iamdoubz 3b4f045bf8 Add Zstd section and update example 2025-10-08 13:57:32 -05:00
iamdoubz e7c1a00aa8 Add zstd module 2025-10-08 13:53:58 -05:00
iamdoubz 2fd6e73a82 Bump freenginx and openssl versions
Additionally tidy up code base
2025-10-08 13:47:20 -05:00
iamdoubz 14d1ce41af Bump freenginx, pcre2, and ssl versions 2025-09-15 13:57:43 -05:00
iamdoubz 19e360d722 Update README.md 2025-07-07 09:57:22 -05:00
iamdoubz d17780f7ca Add KTLS to README 2025-07-02 12:50:40 -05:00
iamdoubz 933338fff9 Bump openssl version 2025-07-02 12:48:41 -05:00
iamdoubz 825a385718 Remove extra quotation 2025-07-02 12:28:33 -05:00
iamdoubz b56a250eed Complete KTLS integration 2025-07-02 12:25:03 -05:00
iamdoubz 70b25ee84a KTLS modprob -> modprobe add make clean 2025-07-02 12:11:10 -05:00
iamdoubz bb4062a76d Fix errors with KTLS compilation 2025-07-02 12:07:10 -05:00
iamdoubz bff6a45aa9 Add KTLS option to script 2025-06-15 12:25:38 -05:00
iamdoubz 86d3f9543b Update dependencies and freenginx version 2025-05-29 05:53:39 -05:00
iamdoubz e26ccfcfe6 Add function, update freenginx, openssl-3.5.0 w/quantum 2025-05-29 05:51:00 -05:00
iamdoubz 398fb97bea Update PCRE2 to latest release
**NOTE**: PCRE2 10.45 _does not_ compile successfully on Windows!
2025-02-10 16:52:39 -06:00
2 changed files with 193 additions and 105 deletions
+13 -4
View File
@@ -3,9 +3,12 @@ Iamdoubz custom freenginx config for Ubuntu 22.04. I was tired of forgetting wha
# Enhancements
- Support for H3/QUIC
- Brotli compression
- GeoIP2 (MaxMind)
- [Brotli compression](https://github.com/google/ngx_brotli)
- [Zstandard compression](https://github.com/HanadaLee/ngx_http_zstd_module)
- [GeoIP2](https://github.com/leev/ngx_http_geoip2_module)
- [Headers-More](https://github.com/openresty/headers-more-nginx-module)
- Quantum cryptography
- KTLS
- debug
# Dependencies
@@ -14,9 +17,15 @@ There are quite a few dependencies to install. The main ones being:
- git
- curl
- wget
- cmake
- [libmaxminddb](https://github.com/maxmind/libmaxminddb)
- And probably others...
# Additional Packages
- [PCRE2](https://github.com/PCRE2Project/pcre2/)
- [zlib](https://www.zlib.net/)
- [openssl](https://github.com/openssl/openssl/)
# How to download
Please use the provided script `freenginx.sh`. Make sure to make it executable first `sudo chmod +x freenginx.sh`. Then run it with `./freenginx.sh`.
@@ -24,8 +33,8 @@ Please use the provided script `freenginx.sh`. Make sure to make it executable f
Type `which nginx` and make a copy i.e. `sudo cp /usr/sbin/nginx /usr/sbin/nginx_apt`. **NOTE**: if you have *not* installed nginx, you do not have to do this step. **NOTE**: this script for freenginx is built as a drop in replacement for nginx.
# Install newly compiled binary
1. `cd /path/to/buildroot/nginx-release-1.27.4`
1. `cd /path/to/buildroot/nginx-release-1.29.4`
2. `sudo make install`
3. Check nginx `sudo nginx -t`
4. Reload nginx `sudo nginx -s reload`
5. Verify new version `sudo nginx -v` should output `nginx version: freenginx/1.27.4 (w/GeoIP2,Brotli,H3,Headers-More,debug)`
5. Verify new version `sudo nginx -v` should output `nginx version: freenginx/1.29.4 (w/GeoIP2,Brotli,H3,Headers-More,Quantum,debug,KTLS)`
+180 -101
View File
@@ -2,124 +2,203 @@
####################################
### START change these variables ###
####################################
V_NGINX="1.27.4"
V_NGINX="1.29.4"
V_ZLIB="1.3.1"
V_PCRE="10.45-RC1"
V_QSSL="3.1.7"
V_PCRE="10.47"
V_QSSL="3.5.4"
V_MAXM="1.12.2"
V_HEAD="0.38"
V_HEAD="0.39"
USE_ZSTD=true
BUILDROOT="/home/iamdoubz/Gits/freenginx-custom"
####################################
#### END change these variables ####
####################################
USE_KTLS=""
BUILD_INFO="w/GeoIP2,Brotli,H3,Headers-More,Quantum,debug"
kernelcheck()
{
MAJOR_VERSION=$(uname -r | awk -F '.' '{print $1}')
MINOR_VERSION=$(uname -r | awk -F '.' '{print $2}')
if [ $MAJOR_VERSION -ge 5 ] && [ $MINOR_VERSION -gt 9 ] || [ $MAJOR_VERSION -ge 6 ] ; then
return true
else
return false
fi
}
check_dir()
{
path=$1
what=$2
if [ ! -d "$path" ]; then
if [ $what = "create" ]; then
echo " "
echo "Creating directory at $path"
mkdir -p "$path"
elif [ $what = "zlib" ]; then
echo " "
echo "zlib Downloading..."
curl -s -L -O "https://www.zlib.net/zlib-$V_ZLIB.tar.gz"
echo "zlib Extracting..."
tar -xzf "zlib-$V_ZLIB.tar.gz"
rm "zlib-$V_ZLIB.tar.gz"
elif [ $what = "pcre" ]; then
echo " "
echo "pcre2 Downloading..."
curl -s -L -O "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-$V_PCRE/pcre2-$V_PCRE.tar.gz"
echo "pcre2 Extracting..."
tar -xzf "pcre2-$V_PCRE.tar.gz"
rm "pcre2-$V_PCRE.tar.gz"
elif [ $what = "openssl" ]; then
echo " "
echo "openssl Downloading..."
curl -s -L -O "https://github.com/openssl/openssl/releases/download/openssl-$V_QSSL/openssl-$V_QSSL.tar.gz"
echo "openssl Extracting..."
tar -xzf "openssl-$V_QSSL.tar.gz"
rm "openssl-$V_QSSL.tar.gz"
elif [ $what = "headers" ]; then
echo " "
echo "Headers More Downloading..."
curl -s -L -O "https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v$V_HEAD.zip"
echo "Headers More Extracting..."
unzip -qq "v$V_HEAD.zip"
rm "v$V_HEAD.zip"
elif [ $what = "brotli" ]; then
echo " "
echo "Brotli Downloading..."
git clone --quiet --recurse-submodules -j8 https://github.com/google/ngx_brotli ngx-brotli
elif [ $what = "zstd" ]; then
echo " "
echo "Zstd Downloading..."
git clone --quiet https://github.com/HanadaLee/ngx_http_zstd_module.git ngx-zstd
elif [ $what = "geoip2" ]; then
echo " "
echo "GeoIP2 Downloading..."
git clone --quiet https://github.com/leev/ngx_http_geoip2_module nginx-geoip2
elif [ $what = "maxmind" ]; then
echo " "
echo "MaxMind downloading..."
curl -s -L -O "https://github.com/maxmind/libmaxminddb/releases/download/$V_MAXM/libmaxminddb-$V_MAXM.tar.gz"
echo "MaxMind Extracting..."
tar -xzf "libmaxminddb-$V_MAXM.tar.gz"
rm "libmaxminddb-$V_MAXM.tar.gz"
cd "libmaxminddb-$V_MAXM"
./configure &>/dev/null
make &>/dev/null
sudo make install &>/dev/null
# sudo sh -c "echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf"
sudo ldconfig &>/dev/null
elif [ $what = "ktls" ]; then
if [ kernelcheck ] ; then
echo " "
echo "Enabling KTLS..."
sudo modprobe tls
USE_KTLS=" enable-ktls"
BUILD_INFO="$BUILD_INFO,KTLS"
fi
elif [ $what = "freenginx" ]; then
echo " "
echo "freenginx Downloading..."
curl -s -L -O "https://github.com/freenginx/nginx/archive/refs/tags/release-$V_NGINX.tar.gz"
tar -xzf "release-$V_NGINX.tar.gz"
rm "release-$V_NGINX.tar.gz"
else
echo " "
echo "Path: $path What: $what"
fi
fi
}
### Main script start
# Create build directory
CURRENTDIR="$BUILDROOT"
if [ ! -d "$CURRENTDIR" ]; then
echo "Creating Build Directory at $BUILDROOT"
mkdir -p "$CURRENTDIR"
fi
check_dir $CURRENTDIR create
cd "$CURRENTDIR"
### START check dependencies ###
# zlib
CURRENTDIR="$BUILDROOT/zlib-$V_ZLIB"
if [ ! -d "$CURRENTDIR" ]; then
echo "zlib Downloading..."
curl -L -O "https://www.zlib.net/zlib-$V_ZLIB.tar.gz"
echo "zlib Extracting..."
tar -xzf "zlib-$V_ZLIB.tar.gz"
rm "zlib-$V_ZLIB.tar.gz"
fi
check_dir $CURRENTDIR zlib
# pcre
CURRENTDIR="$BUILDROOT/pcre2-$V_PCRE"
if [ ! -d "$CURRENTDIR" ]; then
echo "pcre2 Downloading..."
curl -L -O "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-$V_PCRE/pcre2-$V_PCRE.tar.gz"
echo "pcre2 Extracting..."
tar -xzf "pcre2-$V_PCRE.tar.gz"
rm "pcre2-$V_PCRE.tar.gz"
fi
CURRENTDIR="$BUILDROOT/openssl-openssl-$V_QSSL-quic1"
if [ ! -d "$CURRENTDIR" ]; then
echo "openssl Downloading..."
curl -L -O "https://github.com/quictls/openssl/archive/refs/tags/openssl-$V_QSSL-quic1.zip"
echo "openssl Extracting..."
unzip "openssl-$V_QSSL-quic1.zip"
rm "openssl-$V_QSSL-quic1.zip"
fi
check_dir $CURRENTDIR pcre
# openssl
CURRENTDIR="$BUILDROOT/openssl-$V_QSSL"
check_dir $CURRENTDIR openssl
# headers
CURRENTDIR="$BUILDROOT/headers-more-nginx-module-$V_HEAD"
if [ ! -d "$CURRENTDIR" ]; then
echo "Headers More Downloading..."
curl -L -O "https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v$V_HEAD.zip"
echo "Headers More Extracting..."
unzip "v$V_HEAD.zip"
rm "v$V_HEAD.zip"
fi
#### END check dependencies ####
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
### START brotli build ###
check_dir $CURRENTDIR headers
# brotli
CURRENTDIR="$BUILDROOT/ngx-brotli"
if [ ! -d "$CURRENTDIR" ]; then
git clone --recurse-submodules -j8 https://github.com/google/ngx_brotli ngx-brotli
fi
check_dir $CURRENTDIR brotli
cd "$CURRENTDIR"
git pull
git pull --quiet
CURRENTDIR="$BUILDROOT/ngx-brotli/deps/brotli/out"
if [ ! -d "$CURRENTDIR" ]; then
mkdir -p "$CURRENTDIR"
fi
check_dir $CURRENTDIR create
cd "$CURRENTDIR"
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" \
-DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed ..
cmake --build . --config Release --target brotlienc
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
### START geoip2
CURRENTDIR="$BUILDROOT/nginx-geoip2"
if [ ! -d "$CURRENTDIR" ]; then
git clone https://github.com/leev/ngx_http_geoip2_module nginx-geoip2
fi
cd "$CURRENTDIR"
git pull
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
### START libmaxminddb
CURRENTDIR="$BUILDROOT/libmaxminddb-$V_MAXM"
if [ ! -d "$CURRENTDIR" ]; then
echo "MaxMind downloading..."
curl -L -O "https://github.com/maxmind/libmaxminddb/releases/download/$V_MAXM/libmaxminddb-$V_MAXM.tar.gz"
echo "MaxMind Extracting..."
tar -xzf "libmaxminddb-$V_MAXM.tar.gz"
rm "libmaxminddb-$V_MAXM.tar.gz"
cd "libmaxminddb-$V_MAXM"
./configure
make
sudo make install
# sudo sh -c "echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf"
sudo ldconfig
fi
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
### START nginx config ###
CURRENTDIR="$BUILDROOT/nginx-release-$V_NGINX"
if [ ! -d "$CURRENTDIR" ]; then
curl -L -O "https://github.com/freenginx/nginx/archive/refs/tags/release-$V_NGINX.tar.gz"
tar -xzf "release-$V_NGINX.tar.gz"
rm "release-$V_NGINX.tar.gz"
fi
cd "$CURRENTDIR"
make clean
./auto/configure --build="w/GeoIP2,Brotli,H3,Headers-More,debug" --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/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-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module \
--with-http_flv_module --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_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-mail --with-mail_ssl_module \
--with-http_v2_module --with-http_v3_module --with-stream --with-select_module --with-poll_module --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module \
--with-debug --with-zlib=../zlib-$V_ZLIB --with-pcre=../pcre2-$V_PCRE --with-openssl=../openssl-openssl-$V_QSSL-quic1 --with-openssl-opt='no-asm no-tests' \
--add-module='../ngx-brotli' --add-module='../nginx-geoip2' --add-module="../headers-more-nginx-module-$V_HEAD" \
--with-cc-opt="-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-$V_NGINX/debian/debuild-base/nginx-$V_NGINX=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC -I../openssl-openssl-$V_QSSL-quic1/build/include" \
--with-ld-opt="-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie -L../openssl-openssl-$V_QSSL-quic1/build/lib"
-DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed .. &>/dev/null
cmake --build . --config Release --target brotlienc &>/dev/null
make -j8
# zstd
if [ $USE_ZSTD ] ; then
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
CURRENTDIR="$BUILDROOT/ngx-zstd"
check_dir $CURRENTDIR zstd
cd "$CURRENTDIR"
git pull --quiet
fi
# geoip2
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
CURRENTDIR="$BUILDROOT/nginx-geoip2"
check_dir $CURRENTDIR geoip2
cd "$CURRENTDIR"
git pull --quiet
# maxmind
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
CURRENTDIR="$BUILDROOT/libmaxminddb-$V_MAXM"
check_dir $CURRENTDIR maxmind
# ktls
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
CURRENTDIR="$BUILDROOT/ktls"
check_dir $CURRENTDIR ktls
# freenginx
CURRENTDIR="$BUILDROOT"
cd "$CURRENTDIR"
CURRENTDIR="$BUILDROOT/nginx-release-$V_NGINX"
check_dir $CURRENTDIR freenginx
cd "$CURRENTDIR"
echo " "
echo " "
echo "Configuring freenginx..."
make clean &>/dev/null
./auto/configure --build="$BUILD_INFO" --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/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-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module \
--with-http_flv_module --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_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-mail --with-mail_ssl_module \
--with-http_v2_module --with-http_v3_module --with-stream --with-select_module --with-poll_module --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module \
--with-zlib=../zlib-$V_ZLIB --with-pcre=../pcre2-$V_PCRE --with-openssl=../openssl-$V_QSSL --with-openssl-opt="no-asm no-tests enable-tls1_3$USE_KTLS" \
--add-module='../ngx-brotli' --add-module='../nginx-geoip2' --add-module="../headers-more-nginx-module-$V_HEAD" --add-module="../ngx-zstd" \
--with-cc-opt="-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-$V_NGINX/debian/debuild-base/nginx-$V_NGINX=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC -I../openssl-$V_QSSL/build/include" \
--with-ld-opt="-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie -L../openssl-$V_QSSL/build/lib" \
--with-debug > config.log
echo " "
make -j8 > make.log
echo " "
$BUILDROOT/nginx-release-$V_NGINX/objs/nginx -V
echo " "
ls -lh $BUILDROOT/nginx-release-$V_NGINX/objs/nginx
ls -lh $BUILDROOT/nginx-release-$V_NGINX/objs/nginx