Latest News

Build Nginx with PageSpeed, Brotli, OpenSSL from Source

  • Ivan Ivanov
  • Nginx
Build Nginx with PageSpeed, Brotli, OpenSSL from Source

PageSpeed is a set of modules for NGINX and Apache which optimize and measure page performance of websites. Optimization is done by minifying static assets such as CSS and JavaScript, which decreases page load time. PageSpeed Insights is a tool that measures your site’s performance, and makes recommendations for further modifications based on the results.

Brotli is a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling, with a compression ratio comparable to the best currently available general-purpose compression methods. It is similar in speed with deflate but offers more dense compression.

headers-more-nginx-module - Set, Add and Clear Arbitrary Output Headers in NGINX HTTP Servers.

We execute below command lines one by one and after "bash <(curl -f -L -sS \ --nginx-version latest" we will get asked if we want to add any extra Nginx Modules and that is where we select yes and add the "./configure \" part.

wget -O - | tar -xz
wget -O - | tar -xz

git clone
cd ngx_brotli && git submodule update --init

wget -O - | tar -xz

bash <(curl -f -L -sS \
--nginx-version latest

./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/run/ \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--user=nginx \
--group=nginx \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-zlib=/home/zlib-1.2.11 \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_stub_status_module \
--add-module=/home/headers-more-nginx-module-0.33 \
--add-module=/home/openssl-1.1.1b \

Lastly in /etc/nginx/nginx.conf we add below to Activate PageSpeed & Brotli.

# PageSpeed Configuration
pagespeed on;
pagespeed FileCachePath /var/cache/nginx/pagespeed;
pagespeed RewriteLevel CoreFilters;
pagespeed DisableFilters rewrite_images;
pagespeed EnableFilters collapse_whitespace,lazyload_images,insert_dns_prefetch;

brotli on;
brotli_min_length 1000;
brotli_comp_level 5;
brotli_types text/plain
application/json i
7 seconds