Skip to content

Instantly share code, notes, and snippets.

@sfan5
Last active April 12, 2024 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfan5/23c302ded1f474024fb579f920d495db to your computer and use it in GitHub Desktop.
Save sfan5/23c302ded1f474024fb579f920d495db to your computer and use it in GitHub Desktop.
Compiles nginx statically linked with LibreSSL
#!/bin/bash -e
LIBRESSL_VERSION=3.9.1
NGINX_VERSION=1.25.4
NGINX_CONFIG="--with-pcre-jit --with-threads --with-http_ssl_module --with-http_v2_module --with-http_realip_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 " \$ cd nginx; sudo make install"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment