Applicable to:
- Plesk for Linux
Question
Does Plesk support BROTLI (mod_brotli) compression for Apache or Nginx web server?
Answer
This functionality is implemented as of Plesk Obsidian 18.0.33
Brotli compression is enabled by default.
To disable Brotli on a single domain, specify brotli off;
in additional Nginx directives.
To disable Brotli globally run the command:
# plesk bin nginx -d brotli
If you do not want to enable brotli globally for all domains, but prefer to manage brotli compression per website, specify brotli off;
in /etc/nginx/conf.d/yy000_brotli_tweaks.conf
(create this file if absent) and add "brotli on;" in domain's additional Nginx directives.
Note: If web content is served by Apache (I.E.: Nginx is in proxy mode), the gzip may be needed to be disabled in Apache directives HTTP/HTTPS with the following: SetEnv no-gzip 1
Comments
12 comments
Brodle is a must! I'm betting on Plesk to support it.
Since you know the importance of this feature, why do we still have to vote for it?
Hello @Kingsley Felix,
More popular feature is, the higher priority of adding this feature will be for the development team.
Voting for Brotli compression also! It should be more popular :)
Voting for Brotli too!
Is there any way to install by CLI ?
I found one for PHP, one for Apache and one for NGINX.
If yes, which one will work for PHP-FPM?
Hello GetPageSpeed,
Thanks for providing these instructions.
Anyway, mind that in case of problems with Brotli module (or such configuration), we won't be supporting it until we officially provide it ourselves.
DaliAbassi, please check out the previous message from GetPageSpeed.
Thank you Francisco Garcia for your answer, but I'm using Ubuntu and the package from GetPageSpeed is for Centos/RHEL.
You can compile a dynamic module yourself. As a temporary solution:
Updated: added missing Step 9. (Run configure in ginx source directory)
Best way is to run the steps below on your server. (Please keep a backup of your server or at least of your nginx config directory)
You will not replace your nginx binary, this will just compile the ngx_brotli modul.
If something goes wrong just delete the files that loads the module (Step 11. and 12.) or use backup config.
Also Remember that you would have to rebuild this module once Plesk updates it's nginx server.
if nginx configure or make modules fail install missing libraries or take a look at https://talk.plesk.com/threads/how-to-compile-nginx-with-additional-modules-pagespeed-cache_purge-headers-more-and-others.340640/
apt-get build-essential zlib1g-dev libpcre3 libpcre3-dev unzip
Output should be something like this nginx version: nginx/1.16.1
wget https://nginx.org/download/nginx-1.16.1.tar.gz
tar -xzvf nginx-1.16.1.tar.gz
git clone https://github.com/google/ngx_brotli.git && cd ngx_brotli
git submodule update --init --recursive
--add-dynamic-module=/root/addons/nginx/modules/ngx_brotli
--add-dynamic-module=mod_pagespeed
--with-openssl=lib_openssl from your variables
--add-dynamic-module=mod_passenger/src/nginx_module
to your nginx modules directory (/usr/share/nginx/modules)
nano /etc/nginx/modules.conf.d/brotli.conf
With follwing content:
load_module nginx/modules/ngx_http_brotli_filter_module.so;
load_module nginx/modules/ngx_http_brotli_static_module.so;
brotli on;
brotli_comp_level 6;
brotli_static on;
brotli_types application/atom+xml application/javascript application/json application/rss+xml
application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype
application/x-font-ttf application/x-javascript application/xhtml+xml application/xml
font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon
image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml;
Now all static files should be served via brotli. Proxied requests don't seem to work.
Maybe plesk could ad the dynamic compiled modules, just like pagespeed and passenger??
I don't get it.
Could you explain this better "Add the path where of your ngx_brotli install"
where? remove following lines:
Please explain this better.
Newer mind I found this.
https://www.getpagespeed.com/server-setup/nginx/how-to-install-brotli-nginx-module-in-plesk-for-centos-rhel#comment-830
Bragi Austfjord
Thank you for sharing this solution! It might be useful for other Pleskians, too.
Thank you Christoph Flathmann
To me, on step 7 i also needed to remove these lines:
--with-http_ssl_module
--with-http_v2_module
Maybe it's because i compiled on the another machine, not on the prod server, but in the end everything worked without any problems
Please sign in to leave a comment.