Compression

Brotli Static

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

nginx-module-brotli-static

Install

You'll need nginx from nginx.org configured first. These packages won't load on the distro nginx.

Add the Blendbyte repository if you haven't already:

Add Blendbyte repository
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

Then install this module:

Install nginx-module-brotli-static
$ sudo apt install nginx-module-brotli-static

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

Enable module 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

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 example
location /static/ {
  root /var/www/html;
  brotli_static on;
  gzip_static   on;  # gzip fallback for older clients
}

Replacing a Sury package?

This replaces libnginx-mod-http-brotli-static from the old Sury nginx repository. The package declares Replaces and Conflicts so apt handles the swap in one transaction. No manual cleanup needed.

Drop-in replacement
# If you were using Sury, this upgrades in place:
sudo apt install nginx-module-brotli-static

See the full migration guide for the complete Sury-to-Blendbyte migration steps.

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.

https://github.com/google/ngx_brotli ↗

Related modules

← All modules