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…
@nitinnaresh search is your friend, I have 2 different post on how to enable unsupported Brotli
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.
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
@Raphael 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.
- The worker script calls one or more build scripts to update the dynamic modules.
- *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 Brotli module files on your nginx installation today.
Later, some day, Hestia will update its nginx version.
this will generate a version mismatch between the brotli module and the nginx module since brotli is not a module that is delivered with nginx.
When this will happen Your nginx server will fail to start and all your websites will be down after the Hestia update.
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 you will comment/delete the nginx directives in /etc/conf/nginx.conf
or
you will look for the correct version of the brotli module file. Good luck to find it !
or
you can disable the automated HESTIA updates.
But 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:
To the question: “Is it better than gzip”. I wonder if it could trigger problems.
I use wordpress, and wp super cache, and I just discovered the following in .htaccess =>
RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{HTTPS} on
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz -f
RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz" [L]
I wonder if it would be a problem with brotli.
Client sends something like accept-encoding: gzip, deflate, br
Apache picks up a page named index-https.html.gz that was already compressed in gzip, then, it compressses it in brotli? I am concerned about such unexpected consequences when using brotli.
About performance:
I checked with my wordpress website and pageload with gzip (Apache) is faster than Brotli (Apache) even if pages sizes are 10% bigger using Gzip.