Brotli (original) (raw)
Brotli is a general‑purpose, lossless data compression algorithm that uses a variant of the LZ77 algorithm, Huffman coding, and second‑order context modeling. Its compression ratio is comparable to the best currently available general‑purpose compression methods. Its speed is similar to DEFLATE but with denser compression.
The ngx_brotli module enables Brotli compression in F5 NGINX Plus and consists of two modules:
ngx_brotli filter module
– for compressing responses on-the-flyngx_brotli static module
- for serving pre-compressed files
- Check the Technical Specifications page to verify that the module is supported by your operating system.
- If required, install the epel-release dependency
- for Amazon Linux 2 LTS:
sudo amazon-linux-extras install epel -y
sudo amazon-linux-extras install epel -y
- for CentOS, Oracle Linux, and RHEL:
shell
sudo yum update && \
sudo yum install epel-release -y
sudo yum update && \
sudo yum install epel-release -y
Install the Brotli module package nginx-plus-module-brotli
.
- for Amazon Linux 2 LTS, CentOS, Oracle Linux, and RHEL:
shell
sudo yum update && \
sudo yum install nginx-plus-module-brotli
sudo yum update && \
sudo yum install nginx-plus-module-brotli
- for Amazon Linux 2023, AlmaLinux, Rocky Linux:
shell
sudo dnf update && \
sudo dnf install nginx-plus-module-brotli
sudo dnf update && \
sudo dnf install nginx-plus-module-brotli
- for Debian and Ubuntu:
shell
sudo apt update && \
sudo apt install nginx-plus-module-brotli
sudo apt update && \
sudo apt install nginx-plus-module-brotli
- for SLES 15:
shell
sudo zypper refresh && \
sudo zypper install nginx-plus-module-brotli
sudo zypper refresh && \
sudo zypper install nginx-plus-module-brotli
- for FreeBSD:
shell
sudo pkg update && \
sudo pkg install nginx-plus-module-brotli
sudo pkg update && \
sudo pkg install nginx-plus-module-brotli
After installation you will need to enable and configure Brotli modules in NGINX Plus configuration file nginx.conf.
- Enable dynamic loading of Brotli modules with the load_module directives specified in the top-level (“
main
”) context:
nginx
load_module modules/ngx_http_brotli_filter_module.so; # for compressing responses on-the-fly
load_module modules/ngx_http_brotli_static_module.so; # for serving pre-compressed files
http {
#...
}
load_module modules/ngx_http_brotli_filter_module.so; # for compressing responses on-the-fly
load_module modules/ngx_http_brotli_static_module.so; # for serving pre-compressed files
http {
#...
}
- Enable Brotli compression and perform additional configuration as required by the ngx_brotli module. Brotli compression can be configured on the http, server or location levels:
nginx
http {
server {
brotli on;
#...
}
}
http {
server {
brotli on;
#...
}
}
- Test the NGINX Plus configuration. In a terminal, type-in the command:
Expected output of the command:
shell
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf is successful
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf is successful
- Reload the NGINX Plus configuration to enable the module:
- NGINX Module for Brotli Compression Reference
- NGINX Dynamic Modules
- NGINX Plus Technical Specifications
- Uninstalling a Dynamic Module