Skip to content

Instantly share code, notes, and snippets.

@jyxjjj
Created November 12, 2025 09:46
Show Gist options
  • Save jyxjjj/32309ca0488430ede6ed79cfcf7ea2a0 to your computer and use it in GitHub Desktop.
Save jyxjjj/32309ca0488430ede6ed79cfcf7ea2a0 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
mkdir -p /data
mkdir -p /www/wwwlogs
mkdir -p /www/server/nginx
NGINX_VERSION='1.29.3'
NGINX_BANNER='Nginx'
NGINX_BANNER_VERSION='1.29.3'
NGINX_URL="https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz"
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
export socks5_proxy="socks5h://127.0.0.1:7890"
export all_proxy="http://127.0.0.1:7890"
curl -IfSsL https://www.google.com/generate_204 | grep -q '204' || {
echo "Proxy is not working, please check your proxy settings."
exit 1
}
cd /data
if [[ ! -d /data/ngx_brotli ]]; then
git clone --recurse-submodules -j8 https://github.com/google/ngx_brotli.git
fi
cd /data/ngx_brotli/deps/brotli
mkdir -p /data/ngx_brotli/deps/brotli/out
cd /data/ngx_brotli/deps/brotli/out
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
cd /data
if [[ ! -d /data/zstd-nginx-module ]]; then
git clone -j8 https://github.com/tokers/zstd-nginx-module.git
fi
cd /data
curl -fSsL "$NGINX_URL" -o nginx.tar.gz
tar -xzf nginx.tar.gz
chown -R root:root /data
cd nginx-"$NGINX_VERSION" || exit 1
sed -i "s#\"nginx/\"#\"$NGINX_BANNER/\"#" src/core/nginx.h
sed -i "s#\"NGINX\"#\"$NGINX_BANNER\"#" src/core/nginx.h
sed -i "s#\"$NGINX_VERSION\"#\"$NGINX_BANNER_VERSION\"#" src/core/nginx.h
./configure \
--user=www --group=www \
--prefix=/www/server/nginx \
--error-log-path=/www/wwwlogs/error.log \
--http-log-path=/www/wwwlogs/access.log \
--pid-path=/www/wwwlogs/nginx.pid \
--lock-path=/www/wwwlogs/nginx.lock \
--add-module=/data/ngx_brotli \
--add-module=/data/zstd-nginx-module \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_stub_status_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_dav_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_sub_module \
--with-http_v2_module \
--with-http_v3_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-threads \
--with-file-aio \
--without-http_ssi_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--with-openssl-opt='zlib no-ssl3 no-rc2 no-rc4 no-rc5 no-md2 no-md4 enable-ktls -m64 -O3 -march=native -Wl,-flto=jobserver -D_FORTIFY_SOURCE=3' \
--with-ld-opt='-Wl,-s -Wl,-z,relro -Wl,-z,now' \
--with-cc-opt='-m64 -O3 -DTCP_FASTOPEN=23 -ffast-math -march=native -flto=jobserver -fstack-protector-strong -fuse-ld=gold --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wno-implicit-fallthrough -fno-strict-aliasing -fPIC -D_FORTIFY_SOURCE=2' \
>/dev/null
make -j"\$(nproc)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment