Install Brotli for Nginx – CentOS 7

sudo vi /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1

sudo yum install -y curl wget vim git unzip socat bash-completion epel-release socat
sudo yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel
sudo yum groupinstall “Development Tools”
sudo yum install nginx

git clone https://github.com/google/ngx_brotli.git
wget http://nginx.org/download/nginx-1.19.4.tar.gz
sudo tar xzvf nginx-1.19.4.tar.gz

cd nginx-1.19.4
sudo ./configure –with-compat –add-dynamic-module=../ngx_brotli
cd ../ngx_brotli && git submodule update –init && cd /home/adit/nginx-1.19.4
sudo ./configure –with-compat –add-dynamic-module=../ngx_brotli
sudo make modules
sudo cp objs/*.so /etc/nginx/modules
sudo chmod 644 /etc/nginx/modules/*.so

sudo vi /etc/nginx/nginx.conf

# brotli
load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;

http {
:::
# Compression brotli
brotli on;
brotli_comp_level 6;
brotli_static on;
brotli_types *;
:::
}

 

sudo systemctl restart nginx

 

test your compression brotli

Brotli Test