đź“… Updated: February 18, 2026 (Originally published: January 10, 2019)
Brotli is a modern compression algorithm that delivers 15-25% better compression ratios than gzip. With widespread browser support, enabling Brotli compression on your NGINX server is one of the easiest performance wins you can achieve.
This guide shows you how to install the NGINX Brotli module on RHEL-based systems including Rocky Linux, AlmaLinux, CentOS, and Amazon Linux using pre-built RPM packages from the GetPageSpeed repository. For Debian and Ubuntu users, check out our NGINX APT repository which provides the same modules.
Why Use Brotli Compression?
Brotli offers several advantages over traditional gzip compression:
- Better compression ratios: 15-25% smaller files at similar CPU cost
- Faster decompression: Browsers decompress Brotli faster than gzip
- Universal browser support: All modern browsers support Brotli (Chrome, Firefox, Safari, Edge)
Install NGINX Brotli Module
Step 1. Add GetPageSpeed Repository
For Rocky Linux, AlmaLinux, CentOS 8/9, or Fedora:
sudo dnf install -y https://extras.getpagespeed.com/release-latest.rpm
For CentOS/RHEL 7 or Amazon Linux 2:
sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
Note: An active NGINX Extras subscription is required for RHEL-based systems. Fedora users have free access.
Step 2. Install NGINX and Brotli Module
For Rocky Linux, AlmaLinux, CentOS 8/9, or Fedora:
sudo dnf install -y nginx nginx-module-brotli
For CentOS/RHEL 7 or Amazon Linux 2:
sudo yum -y install nginx nginx-module-brotli
Follow the installation prompt to import the GPG public key used for verifying packages.
Step 3. Enable Brotli Module in NGINX
The Brotli package includes two modules:
- ngx_http_brotli_filter_module.so – Compresses responses on-the-fly
- ngx_http_brotli_static_module.so – Serves pre-compressed
.brfiles
Add these lines at the top of /etc/nginx/nginx.conf:
load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;
For most use cases, you only need the filter module. The static module is useful if you pre-compress assets at build time for maximum compression.
Configure Brotli Compression
Create /etc/nginx/conf.d/brotli.conf with your compression settings:
brotli on;
brotli_comp_level 4;
brotli_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.ms-fontobject
application/wasm
application/x-font-opentype
application/x-font-truetype
application/x-font-ttf
application/x-javascript
application/xhtml+xml
application/xml
application/xml+rss
font/eot
font/opentype
font/otf
image/bmp
image/svg+xml
image/vnd.microsoft.icon
image/x-icon
text/cache-manifest
text/calendar
text/css
text/javascript
text/markdown
text/plain
text/vcard
text/vtt
text/x-component
text/xml;
Why compression level 4? Brotli’s sweet spot is level 4, where compression matches or exceeds gzip’s default level 6 while using less CPU time.
Reload NGINX to apply changes:
sudo systemctl reload nginx
Verify Brotli Compression Works
Using curl
Test from the command line:
curl -IL https://example.com -H "Accept-Encoding: br"
Look for Content-Encoding: br in the response headers.
Using Browser DevTools
- Open your site in Chrome or Firefox
- Open Developer Tools (F12)
- Go to the Network tab
- Reload the page
- Click any request and check Response Headers
- Look for
Content-Encoding: br
Pre-Compressed Brotli Files (Optional)
For maximum compression, pre-compress static assets at build time using Brotli’s highest compression level (11). The static module serves these .br files automatically.
Learn more in our guide on serving pre-compressed Brotli files with brotli_static.
PageSpeed Module Compatibility
If you use the PageSpeed NGINX module alongside Brotli, disable PageSpeed’s internal compression:
pagespeed HttpCacheCompressionLevel 0;
This allows the Brotli module to handle compression while PageSpeed handles optimization.
Going Further
For even better compression on modern systems, consider Zstd compression which offers faster compression speeds at similar ratios.
Also check out how to install PageSpeed module for additional performance optimizations.

