Brotli Static

Pre-compressed. Because why compress the same file at request time, forever?

$ sudo apt install nginx-module-brotli-static
Package
nginx-module-brotli-static
Section
Compression
Replaces
libnginx-mod-http-brotli-static
Upstream
github.com/google/ngx_brotli ↗
Distros
Debian 12, 13 · Ubuntu 22.04, 24.04, 26.04
Arch
amd64, arm64

What it does

Brotli static works with the dynamic Brotli module to serve pre-compressed files. When a request comes in with Accept-Encoding: br, nginx looks for a .br version of the file on disk. If it finds one, that gets served. No CPU, no on-the-fly compression. Good for assets that rarely change: JS bundles, CSS, fonts, JSON manifests. Compress them once in your build pipeline (brotli CLI, webpack plugin, Vite plugin) and deploy alongside the originals. The dynamic module covers anything that has no pre-compressed version.

When to use it

  • Serve compressed JS bundles and CSS without runtime CPU overhead
  • Reduce server resource usage on high-traffic static asset endpoints
  • Combine with the dynamic brotli module for complete coverage
  • Deploy pre-compressed files from CI/CD pipelines with no nginx config changes

Configuration

A starting point. Adjust to taste.

nginx.conf
location /static/ {
  root /var/www/html;
  brotli_static on;
  gzip_static   on;  # gzip fallback for older clients
}

Install from scratch

You'll need nginx from nginx.org configured first. These packages won't load on the distro nginx. Then add the Blendbyte repository if you haven't already:

Add repository and install
sudo install -d -m 0755 /etc/apt/keyrings

curl -fsSL https://apt.blendbyte.net/nginx/blendbyte-archive-keyring.gpg \
  | sudo tee /etc/apt/keyrings/blendbyte.gpg >/dev/null

echo "deb [signed-by=/etc/apt/keyrings/blendbyte.gpg] https://apt.blendbyte.net/nginx $(lsb_release -cs) main" \
  | sudo tee /etc/apt/sources.list.d/blendbyte.list

sudo apt update
sudo apt install nginx-module-brotli-static

Most modules auto-enable on install. If yours didn't:

Enable manually (if needed)
$ sudo ln -s /etc/nginx/modules-available/50-mod-brotli-static.conf \
  /etc/nginx/modules-enabled/
$ sudo nginx -t && sudo systemctl reload nginx

Replacing a Sury package?

This replaces libnginx-mod-http-brotli-static from the old Sury nginx repository. The package declares Replaces and Conflicts, so once your apt sources point at nginx.org and Blendbyte, a regular apt upgrade swaps it in. No manual cleanup.

Switching sources also moves you from Sury's nginx binary to nginx.org's. The migration guide walks through it in one go.

Upstream project

We package this from the upstream open-source project. If it's a bug in the module itself (not in our packaging), report it upstream at github.com/google/ngx_brotli ↗