Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Build and install google brotli nginx as a dynamic module (ubuntu xenial)
#install brotli
sudo apt-get install brotli
#check nginx version
nginx -V
#download nginx source
wget http://nginx.org/download/nginx-1.14.1.tar.gz
#extract the source
tar -xzvf nginx-1.14.1.tar.gz
#clone the official nginx brotli module
git clone --recursive https://github.com/google/ngx_brotli.git
#get the nginx build dependecies
sudo apt-get build-dep nginx
#configure the build
nginx -V 2>&1 >/dev/null | grep -o " --.*" | grep -oP .+?(?=--add-dynamic-module)| head -1 > nginx-1.14.1/build_args.txt
cd nginx-1.14.1
./configure --with-compat $(cat build_args.txt) --add-dynamic-module=../ngx_brotli
make install
#copy the dynamic module to your nginx lib
sudo cp objs/ngx_http_brotli_filter_module.so /usr/lib/nginx/modules/
sudo chmod 644 /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so
sudo cp objs/ngx_http_brotli_static_module.so /usr/lib/nginx/modules/
sudo chmod 644 /usr/lib/nginx/modules/ngx_http_brotli_static_module.so
#in yor nginx.conf use
# load_module /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so;
# load_module /usr/lib/nginx/modules/ngx_http_brotli_static_module.so;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.