Many thanks to Scott Helme and his excellent blog posts:
https://scotthelme.co.uk/brotli-compression/
https://scotthelme.co.uk/doing-the-chacha-with-nginx/
yum install git python python-devel gcc zlib perl libxml2 libxslt
mkdir nginx
cd nginx
git clone https://github.com/openssl/openssl
#cd openssl
# git describe --abbrev=0 --tags
#git checkout tls1.3-draft-18
#git checkout tls1.3-draft-19
#make clean
#./config shared enable-tls1_3 --prefix=/usr/local/ssl --openssldir=/usr/local/ssl -Wl,-rpath,'$(LIBRPATH)'
#cd ..
git clone https://github.com/google/brotli.git
cd brotli
sudo python setup.py install
cd tests
make
cd ..
git clone https://github.com/bagder/libbrotli
cd libbrotli
./autogen.sh
./configure
make
sudo make install
cd ..
git clone https://github.com/google/ngx_brotli
cd ngx_brotli
git submodule update --init
cd ..
git clone https://github.com/openresty/headers-more-nginx-module
copy current nginx compile flags
yum install nginx
nginx -V
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.13.3.tar.gz
tar -xzvf nginx-1.13.3.tar.gz
rm nginx-1.13.3.tar.gz
cd nginx-1.13.3
./configure (existing configure arguments) --with-openssl=/usr/local/src/openssl-1.1.0f --add-module=/root/nginx/
ngx_brotli
#./configure (existing configure arguments) --with-openssl=/root/nginx/openssl --with-openssl-opt=enable-tls1_3 --add-module=/root/nginx/ngx_brotli --add-dynamic-module=/root/nginx/headers-more-nginx-module
make
make install
service nginx restart
nginx -V
sudo nano /etc/nginx/nginx.conf
#load_module /root/nginx/headers-more-nginx-modules/ngx_http_headers_more_filter_module.so;
http {
...
brotli on;
brotli_static on;
brotli_types *;
ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305 ECDHE-RSA-CHACHA20-POLY1305 DHE-RSA-CHACHA20-POLY1305";
ssl_protocols TLSv1.2 TLSv1.3;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
...
}
server {
listen 443 ssl http2;
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
...
}
~/nginx/brotli/bin/bro --input main.min.css --output main.min.css.br