Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Building from source

Build the module yourself when no package matches your nginx: a custom build, freenginx, Angie, or an nginx.org version older than the packaged ones.

Requirements

  • Rust 1.89 or newer;
  • libclang (used by nginx-sys to generate bindings);
  • the NGINX source tree, configured with the same arguments as the NGINX binary that will load the module, plus --with-compat. Run nginx -V to see those arguments. Only ./configure is required, not make. A freenginx or Angie source tree works the same way (for Angie, take the arguments from angie -V).

The zstd C library is not needed.

Build

cd nginx-1.30.8
./configure --with-compat <arguments from nginx -V>

cd /path/to/ngx_mzstd
NGINX_BUILD_DIR=/path/to/nginx-1.30.8/objs cargo build --release

The module is written to target/release/libngx_mzstd.so (libngx_mzstd.dylib on macOS). Load it at the top level of nginx.conf:

load_module /path/to/libngx_mzstd.so;

zstd_thread_pool and zstd_parallel_compressors are compiled in only when the NGINX tree was configured with --with-threads.

NGINX forks

freenginx and Angie are supported and tested in CI (freenginx 1.31, Angie 1.12) alongside NGINX 1.28, 1.30 and 1.31. Point NGINX_BUILD_DIR at the fork’s configured tree; nothing else changes.

freenginx:

curl -sSfL https://freenginx.org/download/freenginx-1.31.6.tar.gz | tar xz
cd freenginx-1.31.6
./configure --with-compat <arguments from nginx -V>

cd /path/to/ngx_mzstd
NGINX_BUILD_DIR=/path/to/freenginx-1.31.6/objs cargo build --release

Angie, which names its binary angie:

curl -sSfL https://download.angie.software/files/angie-1.12.6.tar.gz | tar xz
cd angie-1.12.6
./configure --with-compat <arguments from angie -V>

cd /path/to/ngx_mzstd
NGINX_BUILD_DIR=/path/to/angie-1.12.6/objs cargo build --release

Then add load_module /path/to/libngx_mzstd.so; to the fork’s main configuration file (/etc/angie/angie.conf for Angie) and check it with nginx -t or angie -t.

Vendored NGINX

To build against a vendored NGINX instead, enable the vendored feature (see nginx-src). Prefer building against the exact sources and configuration that run in production: NGINX refuses to load a module that is not binary compatible with it.

Next

Configure the module, then check it with nginx -t and a request:

curl -s -o /dev/null -D - -H 'Accept-Encoding: zstd' http://localhost/ | grep -i content-encoding