The mod_brotli module provides the BROTLI_COMPRESS output filter that allows output from your server to be compressed using the brotli compression format before being sent to the client over the network. This module uses the Brotli library found at

Follow the installation procedure steps to install mod_brotli :-

Install Brotli on your server

yum install pcre-devel cmake -ycd usr/local/src
git clone
cd brotli
git checkout v1.0
make && make install

Adding path for dependencies files:

grep "/usr/local/lib/" /etc/ || echo "/usr/local/lib/" >> /etc/

Compile Apache with this flags from CWP Apache rebuild module :


After Apache is rebuilded add this configs and create the config file :

touch /usr/local/apache/conf.d/brotli.conf

Now add this line to /usr/local/apache/conf.d/brotli.conf :

LoadModule brotli_module modules/
<IfModule mod_brotli.c>
BrotliCompressionQuality 6

BrotliFilterNote Input brotli_input_info
BrotliFilterNote Output brotli_output_info
BrotliFilterNote Ratio brotli_ratio_info
LogFormat '"%r" %{brotli_output_info}n/%{brotli_input_info}n (%{brotli_ratio_info}n%%)' brotli
CustomLog "logs/brotli_log" brotli

#Don't compress content which is already compressed
SetEnvIfNoCase Request_URI \
\.(gif|jpe?g|png|swf|woff|woff2) no-brotli dont-vary

#Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

After configuration restart Apache webserver :

service httpd restart

To enable brotli compression for your site add config to .htaccess :

<IfModule mod_brotli.c>
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/ image/x-icon