Enable Brotli mod_brotli

Sounds like an interesting compression module. Does anyone have any experience with it?
 
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.
 
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 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
 
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/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.
 
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.

@D-Lew i gotta bump your post. Trying to get brotli running.

I did exactly your configuration but it's not working.

I'm trying to figure out what im missing here.

I figure i should add mod_brotli.so in httpd-includes.conf, but there is no mod_brotli.so

So noob question, should i install?:

git clone --depth=1 --recursive https://github.com/kjdev/apache-mod-brotli.git
cd apache-mod-brotli
./autogen.sh
./configure
make


This is what i got:
1594296613547.png






Also i was looking at this thread:

Should we add the following to <VirtualHost 1.2.3.4:443>?
<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/vnd.ms-fontobject image/x-icon
</IfModule>
 

Attachments

  • 1594296851658.png
    1594296851658.png
    20.7 KB · Views: 70
Back
Top