Add Brotli compression to Nginx on Ubuntu

Introduction

You can read more here: https://github.com/google/brotli.

Prerequisites

Instruction

Step 1

Download and extract nginx sources. Replace YOUR_NGINX_VERSION by version number from the sudo nginx -v output.

Step 2

Step 3

Step 4

To correctly do this step we need to make nginx from sources with all arguments from current installing.

Run sudo nginx -V command and copy all text from “configure arguments” section after ‘:’ symbol.

Run next commands but replace $CONFIGURE_ARGUMENTS with your configure arguments from the previous output.

Step 5

Step 6

Restart nginx, but check configuration first.

Step 7

Enable Brotli for dynamic content by adding another instruction to the “/etc/nginx/nginx.conf” file in “http” section.

Restart nginx.

Step 8

Check value of a response header with the name “content-encoding”. It should be “br”.

--

--

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store