# Get google/ngx_brotli source code + google/ngx_brotli submodules
git clone git://github.com/google/ngx_brotli.git
git submodule update --init
# Get the currently installed Nginx source code (Debian package)
NGINX_SOURCE=$(ls -td -- */ | head -n 1 | cut -d'/' -f1)
# Find the ./configure line Nginx was compiled with
# *** REQUIRES HUMAN INTERACTION ***
# Call `./configure` with ALL arguments from "configure arguments:" output above, **except** for the `--add-dynamic-module` ones, and append `--add-dynamic-module=../ngx_brotli` to the end
./configure --with-cc-opt='-g -O2 ....................... --add-dynamic-module=../ngx_brotli
# Build and copy build modules to the right place
mkdir -p /usr/local/lib/nginx/modules/
sudo cp objs/ngx_http_brotli_filter_module.so /usr/local/lib/nginx/modules/
sudo cp objs/ngx_http_brotli_static_module.so /usr/local/lib/nginx/modules/