Install Brotli Nginx Module on Debian – Proper Method

amazon-lightsailaptcompressionlinuxnginx

I'm trying to setup brotly compression on a nginx/1.10.3 server running on Debian 9.5 Stretch / Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u5 (on a
lightsail instance). I used the following commands to try to install it:

$ sudo apt-add-repository -y ppa:hda-me/nginx-stable
$ sudo apt-get update
$ sudo apt-get install brotli nginx nginx-module-brotli

Unfortunatly the first one fails:

gpg: keybox '/tmp/tmpwhmks25f/pubring.gpg' created
gpg: /tmp/tmpwhmks25f/trustdb.gpg: trustdb created
gpg: key 1F5EB010C5341279: public key "Launchpad PPA for hda_launchpad" imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no valid OpenPGP data found.

which causes that the package cannot be installed, so running the last command (after suto apt-get update) ends with that the package can't be found:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nginx-module-brotli

I'ved looked up several docs but there are only infos about installing it on CentOS or ubuntu.

Best Answer

There is no official Debian module for nginx (not so far), but you can compile and add dynamic modules for Brotli compression.

What is dynamic module and how to configure it, read documentation.

You can clone brotli modules from here and compile it (see section "Other Platforms - Dynamically loaded" carefully).

Also this guide helped me understand what configure arguments I can remove (spoiler: all dynamic modules, except brotli)

You may need additional dependencies to compile (such as libbrotli-dev and others). Look for another manuals in this direction.