Skip to main content

NGINX

Install NGINX Brotli Module on Rocky Linux, AlmaLinux, CentOS & RHEL

by , , revisited on


We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

đź“… Updated: February 18, 2026 (Originally published: January 10, 2019)

Brotli is a modern compression algorithm that delivers 15-25% better compression ratios than gzip. With widespread browser support, enabling Brotli compression on your NGINX server is one of the easiest performance wins you can achieve.

This guide shows you how to install the NGINX Brotli module on RHEL-based systems including Rocky Linux, AlmaLinux, CentOS, and Amazon Linux using pre-built RPM packages from the GetPageSpeed repository. For Debian and Ubuntu users, check out our NGINX APT repository which provides the same modules.

Why Use Brotli Compression?

Brotli offers several advantages over traditional gzip compression:

  • Better compression ratios: 15-25% smaller files at similar CPU cost
  • Faster decompression: Browsers decompress Brotli faster than gzip
  • Universal browser support: All modern browsers support Brotli (Chrome, Firefox, Safari, Edge)

Install NGINX Brotli Module

Step 1. Add GetPageSpeed Repository

For Rocky Linux, AlmaLinux, CentOS 8/9, or Fedora:

sudo dnf install -y https://extras.getpagespeed.com/release-latest.rpm

For CentOS/RHEL 7 or Amazon Linux 2:

sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm

Note: An active NGINX Extras subscription is required for RHEL-based systems. Fedora users have free access.

Step 2. Install NGINX and Brotli Module

For Rocky Linux, AlmaLinux, CentOS 8/9, or Fedora:

sudo dnf install -y nginx nginx-module-brotli

For CentOS/RHEL 7 or Amazon Linux 2:

sudo yum -y install nginx nginx-module-brotli

Follow the installation prompt to import the GPG public key used for verifying packages.

Step 3. Enable Brotli Module in NGINX

The Brotli package includes two modules:

  • ngx_http_brotli_filter_module.so – Compresses responses on-the-fly
  • ngx_http_brotli_static_module.so – Serves pre-compressed .br files

Add these lines at the top of /etc/nginx/nginx.conf:

load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;

For most use cases, you only need the filter module. The static module is useful if you pre-compress assets at build time for maximum compression.

Configure Brotli Compression

Create /etc/nginx/conf.d/brotli.conf with your compression settings:

brotli on;
brotli_comp_level 4;
brotli_types
    application/atom+xml
    application/javascript
    application/json
    application/ld+json
    application/manifest+json
    application/rss+xml
    application/vnd.ms-fontobject
    application/wasm
    application/x-font-opentype
    application/x-font-truetype
    application/x-font-ttf
    application/x-javascript
    application/xhtml+xml
    application/xml
    application/xml+rss
    font/eot
    font/opentype
    font/otf
    image/bmp
    image/svg+xml
    image/vnd.microsoft.icon
    image/x-icon
    text/cache-manifest
    text/calendar
    text/css
    text/javascript
    text/markdown
    text/plain
    text/vcard
    text/vtt
    text/x-component
    text/xml;

Why compression level 4? Brotli’s sweet spot is level 4, where compression matches or exceeds gzip’s default level 6 while using less CPU time.

Reload NGINX to apply changes:

sudo systemctl reload nginx

Verify Brotli Compression Works

Using curl

Test from the command line:

curl -IL https://example.com -H "Accept-Encoding: br"

Look for Content-Encoding: br in the response headers.

Using Browser DevTools

  1. Open your site in Chrome or Firefox
  2. Open Developer Tools (F12)
  3. Go to the Network tab
  4. Reload the page
  5. Click any request and check Response Headers
  6. Look for Content-Encoding: br

Pre-Compressed Brotli Files (Optional)

For maximum compression, pre-compress static assets at build time using Brotli’s highest compression level (11). The static module serves these .br files automatically.

Learn more in our guide on serving pre-compressed Brotli files with brotli_static.

PageSpeed Module Compatibility

If you use the PageSpeed NGINX module alongside Brotli, disable PageSpeed’s internal compression:

pagespeed HttpCacheCompressionLevel 0;

This allows the Brotli module to handle compression while PageSpeed handles optimization.

Going Further

For even better compression on modern systems, consider Zstd compression which offers faster compression speeds at similar ratios.

Also check out how to install PageSpeed module for additional performance optimizations.

D

Danila Vershinin

Founder & Lead Engineer

NGINX configuration and optimizationLinux system administrationWeb performance engineering

10+ years NGINX experience • Maintainer of GetPageSpeed RPM repository • Contributor to open-source NGINX modules

  1. Hugh Pratt

    I already have Nginx installed. Will this reinstall it? I wonder if I’ll screw up any modules etc. I had installed with yum install Nginx command. Not sure if any special modules were installed. Can I therefore simply install the Brotli only?

    Reply
    • Danila Vershinin

      I don’t know which repository you had installled Nginx from but most likely you’ll be offered upgrade to our repository’s Nginx. It should go smooth. If not sure, backup /etc/nginx first.

      Reply
      • Hugh Pratt

        Which version of Nginx will this be?

        Reply
        • Danila Vershinin

          Latest stable nginx 1.14.2 at present.

          Reply
          • Hugh Pratt

            Thank you. Yes that’s what I have. I use certs from Let’s Encrypt and ssl etc. All is setup in Nginx.conf. Will all that’s remain intact if I copy the .conf files back after install? Or do I have to change this at all? Can I just leave Nginx as it is and only additionally install Brotli and maybe Headers More? Or will I have to reinstall everything?

          • Danila Vershinin

            It depends on repository where you installed nginx from. If from official stable nginx repository then you will only install the module. Either way, it will either work or not. Your nginx.conf will not be affected.

  2. Hugh Pratt

    I installed nginx from generic yum. EPEL and REMI are in the list I think. Will I still be able to do this one above?

    Reply
    • Danila Vershinin

      Nothing bad will happen if you just try to follow the provided instructions 🙂 Let me know how it goes.

      Reply
      • Hugh Pratt

        Thank you, this is very helpful. I’ve installed it and it’s working. The content-encoding shows in Curl. However, questions:

        In your sample encoding types you have not included JPG, PNG, SVG files. Is this intentional?
        Secondly I have the gzip stuff from before. Should I comment it all out, or leave it and have Brotli as an additional parameter? Right now my nginx.conf has the following. I think the gzip stuff for MSIE6 etc may be not necessary anymore? But the listing of “gzip_types” has several file types that are not in your recommended Brotli list.

        Thanks!

        — NGINX.CONF —

        gzip                  on;
          gzip_static           on;
          gzip_disable          "MSIE [1-6].";
          gzip_disable          "msie6";
          gzip_vary             on;
          gzip_proxied          any;
          gzip_comp_level       9;
          gzip_buffers          128 16k;
          gzip_http_version     1.1;
          gzip_types            text/plain text/css
                                application/json application/javascript application/x-javascript text/javascript 
                                text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml
                                image/png image/gif image/jpeg
                                ;
        
        brotli                on;
          brotli_types          text/xml    image/svg+xml   application/x-font-ttf 
                                image/vnd.  microsoft.icon  application/x-font-opentype 
                                application/json    font/eot   application/vnd.ms-fontobject   application/javascript 
                                font/otf    application/xml   application/xhtml+xml   text/javascript
                                application/x-javascript   text/plain     application/x-font-truetype   application/xml+$
                                image/x-icon    font/opentype   text/css   image/x-win-bitmap;
        
        Reply
        • Danila Vershinin

          SVG images are already included (there is image/svg+xml), while JPEG and PNG are not compressible formats. You should keep gzip directives as GZip encoding will still be used for clients that support only GZip and have no knowledge about Brotli.

          Reply
  3. nhson47ggs

    “yum install nginx nginx-module-brotli”
    No package nginx-module-brotli available.

    Reply
    • Danila Vershinin

      Have you run yum install https://extras.getpagespeed.com/release-latest.rpm

      Reply
  4. Hien D. Nguyen

    Somehow when I run “yum install nginx” (step 2), it tries to install (nginx-1.16.0-1.el7.ngx.x86_64) which does exists and causes Error downloading packages:
    1:nginx-1.16.0-1.el7.ngx.x86_64: [Errno 256] No more mirrors to try.

    Any advises?

    Reply
    • Danila Vershinin

      Please provide complete command you run with complete output.

      Reply
  5. Scott MacDonald

    Installing this broke nginx for me. Any ideas?

    running sudo nginx -t complains about conflicts with a lot of modules, such as:

    nginx: [emerg] module "/usr/lib64/nginx/modules/ngx_http_geoip_module.so" version 1012002 instead of 1016001 in /usr/share/nginx/modules/mod-http-geoip.conf:1
    nginx: configuration file /etc/nginx/nginx.conf test failed

    and

    nginx: [emerg] module "/usr/lib64/nginx/modules/ngx_http_image_filter_module.so" version 1012002 instead of 1016001 in /usr/share/nginx/modules/mod-http-image-filter.conf:1
    nginx: configuration file /etc/nginx/nginx.conf test failed

    Reply
    • Danila Vershinin

      Hi Scott,

      Try running yum list installed | grep nginx and post the output here.
      Without looking, it seems that you have installed NGINX from EPEL repository (?) or elsewhere.
      … Which is more or less impossible though, because the nginx-module-brotli has a hard dependency on newer (than at least EPEL provides) NGINX version.

      Reply
      • Scott MacDonald

        I did indeed install nginx from epel, pretty new CentOS install from last week. Looks like when I installed with the instructions above it updated to nginx from your repo, but all my modules are still from the epel nginx version?

        Here’s my results from yum list installed | grep nginx

        nginx.x86_64 1:1.16.1-1.el7.ngx @getpagespeed-extras
        nginx-all-modules.noarch 1:1.12.2-3.el7 @epel
        nginx-filesystem.noarch 1:1.12.2-3.el7 @epel
        nginx-mod-http-geoip.x86_64 1:1.12.2-3.el7 @epel
        nginx-mod-http-image-filter.x86_64 1:1.12.2-3.el7 @epel
        nginx-mod-http-perl.x86_64 1:1.12.2-3.el7 @epel
        nginx-mod-http-xslt-filter.x86_64 1:1.12.2-3.el7 @epel
        nginx-mod-mail.x86_64 1:1.12.2-3.el7 @epel
        nginx-mod-stream.x86_64 1:1.12.2-3.el7 @epel
        nginx-module-brotli.x86_64 1:1.16.1.0.1.2-1.el7.gps @getpagespeed-extras
        python2-certbot-nginx.noarch 0.36.0-1.el7 @epel

        Reply
        • Danila Vershinin

          The official NGINX package (the one you installed from our repo is the exact copy of it) does not obsolete all NGINX-related module packages from EPEL. You can cleanup the EPEL NGINX packages via something like: yum remove $(yum list installed | grep 'nginx.*@epel' | awk '{ print $1 }')

          Reply
          • Scott MacDonald

            Thanks, removed the incompatible packages and all seems to be working well.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.