Brotli on hestia, is it better than gzip on hestia? What are the steps to install brotli?

brotli on hestia, is it better than gzip on hestia? What are the steps to install brotli?

Brotli needs a customized nginx version, which you will need to compile on your own. Currently we do not have any docs or can provide a step to step guide how to implement it - basicly you could use a simple “how to nginx brotli”-search term to find a tutorial - but don’t forget to set your nginx package in apt on hold, otherwise it will get overwritten due to a update.

Hello,
First of all, I would like to suggest you to use CF, so you’ll get Brotli Compression from cloud side.
on the other way, you can use this guide.
https://www.mysterydata.com/how-to-enable-brotli-compression-in-nginx-cwp-vestacp-and-on-linux-os/

My Opinion - Both are Good, but currently GZIP is better, brotli may take over it very soon…

1 Like

@nitinnaresh search is your friend, I have 2 different post on how to enable unsupported Brotli :slight_smile:
You can either install on existing nginx installed by Hestia or replace both are still unsupported so at your own risk

Both of these you need to add in you Brotli settings to enable.

Something like this

brotli on;
brotli_comp_level 6;
brotli_static 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+rss image/x-icon font/opentype text/css image/x-win-bitmap;

Option #1 Tested and works fine (Auto update also works)
May 15

If you want to install Brotli that will update its modules when Nginx does use this guide, don’t forget to chmod +x the files you create or when there is an update Nginx will not work.

on this part I set the path directly into /etc/nginx/modules/

moddir=/path/to/modules/directory

Guide link below to create the script, apt hook and worker

https://www.majlovesreg.one/adding-brotli-to-a-built-nginx-instance

Option #2 Replace - In my tests it works fine.

Jun 30

Test on your own install at your own risk and you need to edit the Nginx config file with Hestia specific requirements

Have been playing around with Ubuntu 20.04 install with Hestia 1.2.0 and can confirm Nginx-ee works adding the following features listed, I did find in the Hestia update status still showed older version but that is to be expected it not showing Nginx 1.19.0. Can restart Nginx and edit configs in Hestia panel

Have tested after install and everything is working that was installed, selected OpenSSL from system and added brotli config in nginx config. update to another dev branch did not overwrite settings.

Used app installer for Wordpress which worked fine.

You can choose to auto update by installing the cron job.

  • Compile the latest Nginx releases : stable or mainline
  • Install Nginx or replace Nginx package previously installed
  • Nginx built-in modules selection
  • Nginx Third-party modules selection
  • Dynamic modules support
  • Brotli Support
  • TLS v1.3 support (Final)
  • OpenSSL (1.1.1g or 3.0.0-dev or from system-lib) or LibreSSL
  • Cloudflare HPACK
  • Cloudflare zlib
  • Automated nginx updates cronjob
  • Compilation with GCC-7/8
  • Security hardening and performance optimization enabled with proper GCC flags

Compatibility

Recommended

  • Ubuntu 20.04 LTS (Focal)
  • Ubuntu 18.04 LTS (Bionic)
  • Debian 10 (Buster)

Also compatible

  • Ubuntu 19.10 (Eoan)
  • Debian 9 (Stretch)

Nginx-ee

https://github.com/VirtuBox/nginx-ee

@ScIT you can use apt hooks and worker scripts instead of holding packages back as listed at option #1 link - full guide on how to add the dynamic modules for Brotli

Hook to apt and call a worker script.

  1. The worker script calls one or more build scripts to update the dynamic modules.
  2. *Build scripts will build and install the new modules right before NGINX upgrades.

/etc/apt/apt.conf.d/ :

and a worker script in

/usr/local/sbin/nginx-mod-preinstall

I think it is dangerous to install Brotli on a Hestia installation.
let’s imagine you install the nginx modules today.

Later, some day, Hestia will update its nginx version, there will be a version mismatch between the brotli module and the nginx module.
Your nginx will fail to start and all your websites will be down after an update of hestia.

In the nginx log, you will find an error like this one:

nginx: [emerg] module “/etc/nginx/modules/ngx_http_brotli_filter_module.so” version 1021003 instead of 1021006 in /etc/nginx/nginx.conf:9

Then, you will have two options: Either your comment/delete the nginx directives in /etc/conf/nginx.conf
or
you look for the correct version of the broli module file. Good luck to find it !
I found a way to find it by compiling nginx on a test server and downloading the .so files.

but then, someday, when hestia will update Nginx, the nginx service will crash again, and you will have to find the module manually again.

Is it worth it?

Hestia does not upgrade nginx it self.

You can also mark nginx it self and preform the updates ad your own convince…

Will contain contain the code to build the packages your self…

It is also possible to simply add brotli to apache 2:

1 Like