Enable Brotli mod_brotli

ViAdCk

Verified User
Joined
Feb 14, 2005
Messages
272
Sounds like an interesting compression module. Does anyone have any experience with it?
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,255
Location
GMT +7.00
No, it should not be empty. Run

Code:
./build version
to make sure you are running custombuild 2.x. If you do have custombuild 2.x then you should run ./build update to recover missing/corrupted files. If your version is 1.x then you need to migrate to 2.x.
 

pmjcreations

Verified User
Joined
Jul 3, 2019
Messages
70
I haven't tried this.

But this guide will also be talking about standalone Nginx.

Other experienced community members here may help.

Don't forget to share if you make it work :)
 

kang28ivan

Verified User
Joined
Mar 16, 2017
Messages
33
I haven't tried this.

But this guide will also be talking about standalone Nginx.

Other experienced community members here may help.

Don't forget to share if you make it work :)
I think you have tried it :)
I will wait for other members to share their experiences, want to try but fear that something will go wrong because the production server is used
 

D-Lew

New member
Joined
Jan 23, 2020
Messages
1
Hope this isn't too much of a necro bump. I was interested in trying this out today so I've done the following for my CentOS installation:

  1. yum install epel-release and enable the repo
  2. yum install brotli brotli-devel
  3. Using https://help.directadmin.com/item.php?id=191 add "--with-brotli" to custom/ap2/configure.apache
  4. ./build apache
  5. At this point, mod_brotli is installed and technically enabled, but not configured. I found out that even with it configured in /etc/httpd/conf/extra/httpd-includes.conf the browser was sending Accept-encoding gzip, deflate, br so gzip was still being preferred over brotli. So In order to do so, I swapped it for gzip by overriding the extra/http-deflate.conf file
Code:
cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2/conf/extra
cp -Rp configure/ap2/conf/extra/httpd-deflate.conf custom/ap2/conf/extra

Here is my configuration in custom/ap2/conf/extra/extra/httpd-deflate.conf

# Brotli

<IfModule brotli_module>
  # Compression
  ## BrotliCompressionQuality: 0-11 (default: 11)
  BrotliCompressionQuality 5
  ## BrotliCompressionWindow: 10-24 (default: 22)
  BrotliCompressionWindow 22


  # Logging
  # Filter note
  BrotliFilterNote Input  brotli_in
  BrotliFilterNote Output brotli_out
  BrotliFilterNote Ratio  brotli_ratio

  #LogFormat '"%r" %{brotli_out}n/%{brotli_in}n (%{brotli_ratio}n)' brotli
  #CustomLog /var/log/httpd/brotli_access.log brotli


  # Output filter

  AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/css text/xml
  AddOutputFilterByType BROTLI_COMPRESS text/css
  AddOutputFilterByType BROTLI_COMPRESS application/x-javascript application/javascript
  AddOutputFilterByType BROTLI_COMPRESS application/rss+xml
  AddOutputFilterByType BROTLI_COMPRESS application/xml
  AddOutputFilterByType BROTLI_COMPRESS application/json


  # Global output filer if necessary.
  # SetOutputFilter BROTLI
  # SetEnvIfNoCase Request_URI \.txt$ no-br


</IfModule>

# End Brotli
Once this is set, run ./build rewrite_confs and the http-deflate.conf will be overwritten with the brotli-specific conf. Most major browsers by now should support this.

(I borrowed some of this from https://ayesh.me/apache-brotli although at this point, some of the directives mentioned seemed outdated.)

There is probably a better way to accomplish this. Also, I'm still testing the BrotliCompressionQuality value to determine the best compression ratio versus website speed. But for those interested in trying this out, this will probably work as a start.

I'll probably play with this a bit longer here and there to see how well it works, but if anyone has feedback on a more elegant way to get br encoding preferred over gzip that would be interesting.
 
Top