NGINX / Server Setup

How to install the Better Brotli NGINX module in Plesk for CentOS/RHEL 7 or 8

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.

Plesk is a modern alternative to cPanel and provides a web interface for managing websites in bulk.

Although my personal view on control panels is beyond negative, I’ve spent some time looking at how to get a missing feature for Plesk – Brotli compression.

Why did I bother? I’ve had a repository subscriber asking whether NGINX modules are compatible with Plesk.

My answer was that “Plesk is likely to have their own repo”.
Later this was confirmed and I simply got curious whether things with Plesk can be improved with supplementary packaging effort.

And so, meet the Better Brotli NGINX module for Plesk. Let’s go through some quick steps on bringing Brotli compression to Plesk.

Notes about Plesk own Brotli module for NGINX

For months, the GetPageSpeed repository has been the only source of the NGINX Brotli module for the Plesk’s own platform.
In late January 2021, Plesk shipped the Brotli module within its sw-nginx package.
The way it was done pretty much sucks for production due to several reasons:

  • There is no clear version information of the Brotli module, so it is subject to 100% CPU bug
  • What’s worse it’s not using a secure system Brotli library, so even security aside, it will have a higher memory consumption

To deal with all this mess, you can instead use our Plesk compatible NGINX Brotli module – The better Brotli NGINX module for Plesk.


  • CentOS/RHEL 7 or CentOS/RHEL 8
  • Latest Plesk
  • 2 minutes of free time

Step 1. Install GetPageSpeed repository

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

Needless to say, you have to subscribe.

Step 2. Install Brotli NGINX module

sudo yum install sw-nginx-module-brotli

Step 3. Disable Plesk Brotli module and Enable Better Brotli module

sudo plesk bin nginx -d brotli
sudo plesk sbin nginx_modules_ctl --enable better-brotli 

PageSpeed module compatibility

As it stands, the PageSpeed NGINX module does not support Brotli compression internally.
You can use if together with the Brotli NGINX module, but you will have to disable internal PageSpeed compression by editing /etc/nginx/nginx.conf and specifying pagespeed HttpCacheCompressionLevel 0;, e.g.:

http {
    pagespeed HttpCacheCompressionLevel 0;

This will ensure that the Brotli compression works, at the cost of storing optimized assets uncompressed.

Step 4. Enable Brotli compression for all websites

Create the file /etc/nginx/conf.d/brotli.conf with contents:

brotli on;
brotli_types text/xml
brotli_comp_level 4;
sudo nginx -t && sudo systemctl restart nginx

(we have to restart NGINX as opposed to reloading its config due to a bug in Plesk).

As an alternative to enabling Brotli for all websites, you can enable Brotli compression for a specific website only.
Open the website’s settings in Plesk admin and navigate to its Hosting & DNS -> Apache & nginx Settings .
Scroll down to “Additional nginx directives” and paste in the same lines as above.
Then similarly, restart NGINX.

Welcome to NGINX with Brotli support 🙂

Verify Brotli compression works

Via Command-Line

It’s easiest to launch the Terminal app (if you have OS X) and check if your NGINX emits Brotli encoded responses.

Simply use curl like this:

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

As long as you see the response includes Content-Encoding: br, it means that NGINX properly handles Brotli compression.

Using CLI to check Brotli support, implies at least some knowledge of working with the Terminal app. So you can use your browser method instead.

Via browser

  • Launch Chrome browser and navigate to your website
  • Right-click anywhere on the opened page and choose “Inspect”.
  • Developer tools sidebar will open.
  • Click on “Network” in the developer tools sidebar, then “Doc”. This tells Chrome to log only requests to the main document.
  • Now reload the page, and expand the log entry which was created by clicking it.
  • Scroll down to “Response Headers” and find “Content-Encoding” header. The value of “br” means that the response was encoded via Brotli.
Plesk with Brotli
Plesk with Brotli


Enabling module

If running plesk sbin nginx_modules_ctl --enable better-brotli yields error:

START nginx_modules_ctl –enable better-brotli
exit status 1

There are 2 common reasons for this.

First, NGINX may be currently disabled in Plesk. Ensure that NGINX is enabled in the first place:

plesk sbin nginxmng -e

The other reason is misplacing the directive for loading the Plesk NGINX modules. In the file /etc/nginx/nginx.conf, ensure that the following line is located outside any context and not commented:

include /etc/nginx/modules.conf.d/*.conf;

The meaning of “outside any context” is that the directive outside of any curly braces { ... }. It should be simply at the top of the configuration file.

There’s more

NGINX modules for Plesk allow both performance and security. There are more than 50 Plesk-compatible NGINX modules available through our repository.

Also, be sure to check out secure NGINX configuration for WordPress in Plesk which leverages some of those modules.

  1. tiagobahi

    Guys… You are amazing… The brotli module works correctly and it has full compatible with Plesk.

  2. David

    Do you think this would work with Ubuntu as well?

  3. Mike

    Hm, 30$ per month just to have the brotli extension? Absurd…

    • Danila Vershinin


      The current pricing is $30 per first month and $10 for each following month.

      There is currently only the Brotli NGINX module that is highly compatible with Plesk.
      Other NGINX modules in our collection are not yet built for NGINX compatibility.

      But the repository subscription is not just about NGINX modules. You get access to the vast array of packages in the repository, including drop-in libraries that will improve your server performance.
      See faster Zlib by Intel/Cloudflare, MozJPEG encoding library,
      just for a couple of examples. You simply install those to make your server faster/better, with zero configuration.

      Of course, there’s far beyond that, you can see the list of all packages available on the repository page (table with repoview links).

    • Danila Vershinin

      We’ve pushed several additional NGINX modules for Plesk. For example application, check secure WordPress configuration.

  4. cliqerio

    Where do I add ‘pagespeed HttpCacheCompressionLevel 0;’?
    Also how do I check that brotli has been installed successfully and sites are using it?

    • Danila Vershinin

      The pagespeed HttpCacheCompressionLevel 0; can be added at the top of http { } configuration section in /etc/nginx/nginx.conf.
      Depending on where you have placed directives for PageSpeed enablement, you might have to place it there instead.

      Added section to this post titled “Verify Brotli compression works”, the easiest way to check if it works is simply checking headers in Chrome.
      Alternatively, use KeyCDN tools Brotli test or our performance test which has Brotli as one of the checks.

  5. Danila Vershinin

    There are now over 50 installable Plesk-compatible NGINX modules available through our repository. Check out NGINX Extras for Plesk.

  6. Bragi Austfjörð

    Could you tell me how I can uninstall this from my plesk server. Plesk added brotli.

    • Danila Vershinin

      The same way it was installed, via yum, e.g.: yum remove sw-nginx-module-brotli
      The Plesk-created module does not rely on secure system Brotli library and has no clear version specifier.
      Thus it is hardly suitable for production use. Added notes to this post.
      GetPageSpeed packages updated so the better Brotli module can be still installed alongside the lousy one by Plesk (which can be disabled).


Leave a Reply

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

%d bloggers like this: