Last active
May 18, 2025 10:27
-
-
Save sfan5/23c302ded1f474024fb579f920d495db to your computer and use it in GitHub Desktop.
Compiles nginx statically linked with LibreSSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
LIBRESSL_VERSION=4.1.0 | |
NGINX_VERSION=1.28.0 | |
NGINX_CONFIG=( | |
--with-pcre-jit --with-threads | |
--with-http_ssl_module | |
--with-http_v2_module | |
--with-http_realip_module | |
--with-http_stub_status_module | |
--with-http_auth_request_module | |
) | |
[ -f libressl.tar.gz ] || \ | |
wget "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-$LIBRESSL_VERSION.tar.gz" \ | |
-O libressl.tar.gz | |
[ -d libressl ] || { | |
mkdir libressl | |
tar -xaf libressl.tar.gz --strip-components=1 -C libressl | |
} | |
cd libressl | |
# different openssldir so it doesn't conflict with a system install | |
./configure --prefix=/ --with-openssldir=/etc/libressl --disable-shared | |
make -j4 | |
make DESTDIR=$PWD/_install install | |
[ -d _install/lib64 ] && ln -s lib64 _install/lib | |
cd .. | |
[ -f nginx.tar.gz ] || \ | |
wget "https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz" -O nginx.tar.gz | |
[ -d nginx ] || { | |
mkdir nginx | |
tar -xaf nginx.tar.gz --strip-components=1 -C nginx | |
sed 's|/\.openssl/|/_install/|g' -i nginx/auto/lib/openssl/conf | |
echo >nginx/auto/lib/openssl/make | |
} | |
cd nginx | |
./configure "${NGINX_CONFIG[@]}" --with-openssl=$PWD/../libressl | |
make -j4 | |
strip -s objs/nginx | |
cd .. | |
echo | |
echo "Done." | |
echo "If you want to install nginx system-wide run:" | |
echo " \$ sudo make -C nginx install" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment