1.Uninstall old nginx and install latest nginx
yum remove nginx -y
#vi /etc/yum.repos.d/nginx.repo
Then copy and paste these lines into the file and save it.
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
#yum update -y
#yum install nginx -y
2.Installing dependencies for brotli
#yum groupinstall 'Development Tools' -y
#yum install gcc-c++ flex bison yajl yajl-devel curl-devel curl GeoIP-devel doxygen zlib-devel -y
#yum install lmdb lmdb-devel libxml2 libxml2-devel ssdeep ssdeep-devel lua lua-devel pcre-devel -y
3.download file mkbrotli from
Adding Brotli to an Already-built NGINX Instance
#cp ~/mkbrotli /usr/local/sbin/mkbrotli
#chmod +x /usr/local/sbin/mkbrotli
4.Install brotli with correct version of nginx
#nginx -v
nginx version: nginx/1.19.1
#/usr/local/sbin/mkbrotli 1.19.1
Sucessfully built and installed latest Brotli for NGINX 1.19.1
Modules can be found in /usr/lib64/nginx/modules
Next step: Configure dynamic modules and reload/restart NGINX.
5.Add modules in nginx conf
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 { ....... # Brotli include global/brotli.conf; ........
vi /etc/nginx/global/brotli.conf
brotli on; brotli_comp_level 4; brotli_buffers 32 8k; brotli_min_length 100; brotli_static on; brotli_types text/xml image/svg+xml application/x-font-ttf image/vnd.microsoft.icon application/x-font-opentype application/json font/eot application/vnd.ms-fontobject application/javascript font/otf application/xml application/xhtml+xml text/javascript application/x-javascript text/plain application/x-font-truetype application/xml+rss image/x-icon font/opentype text/css image/x-win-bitmap;
#nginx -t
#systemctl start nginx
6.Testing and check Content-Encoding:br
curl -IL http://localhost -H "Accept-Encoding: br"
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 13 May 2020 02:27:37 GMT
Content-Type: text/html
Last-Modified: Tue, 21 Apr 2020 15:07:31 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: W/"5e9f0c33-264"
Content-Encoding: br