Posted June 14, 20231 yr comment_54 Brotli compression for Apache will save you from slow compression speed as it uses latest compression technology developed by google. The mod_brotli module provides the BROTLI_COMPRESS output filter that allows output from your server to be compressed using the brotli compression format before being sent to the client over the network. This module uses the Brotli library found at https://github.com/google/brotli. Follow the installation procedure steps to install mod_brotli :- Installing Brotli on your server: yum install pcre-devel cmake -y cd /usr/local/src git clone https://github.com/google/brotli.git cd brotli git checkout v1.0 ./configure-cmake make && make install Adding path for brotli dependencies files (run this commands one by one): grep "/usr/local/lib/" /etc/ld.so.conf || echo "/usr/local/lib/" >> /etc/ld.so.conf ldconfig Compile Apache with this flags from CWP Apache rebuild module WebServer Settings > Apache Re-Build then select the latest Apache version from dropdown and add these flags to “Configure options and build” and hit “Rebuild Apache” --enable-brotli --with-brotli=/usr eg : After Apache is rebuilded create the config file : nano /usr/local/apache/conf.d/brotli.conf Now add this line to /usr/local/apache/conf.d/brotli.conf : LoadModule brotli_module modules/mod_brotli.so <IfModule mod_brotli.c> BrotliCompressionQuality 6 # To enable globally #AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon BrotliFilterNote Input brotli_input_info BrotliFilterNote Output brotli_output_info BrotliFilterNote Ratio brotli_ratio_info LogFormat '"%r" %{brotli_output_info}n/%{brotli_input_info}n (%{brotli_ratio_info}n%%)' brotli CustomLog "logs/brotli_log" brotli #Don't compress content which is already compressed SetEnvIfNoCase Request_URI \ \.(gif|jpe?g|png|swf|woff|woff2) no-brotli dont-vary #Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </IfModule> to enable brotli for all of your sites remove “#” before from AddOutputFilterByType ** BrotliCompressionQuality 6 for better compression you can select value 0-11 i’ll recommend value 6 After configuration restart Apache webserver : service httpd restart To enable brotli compression for your site add this config to .htaccess : <IfModule mod_brotli.c> AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon </IfModule>
June 14, 20231 yr comment_58 11 hours ago, Sandeep B. said: Brotli compression for Apache will save you from slow compression speed as it uses latest compression technology developed by google. The mod_brotli module provides the BROTLI_COMPRESS output filter that allows output from your server to be compressed using the brotli compression format before being sent to the client over the network. This module uses the Brotli library found at https://github.com/google/brotli. Follow the installation procedure steps to install mod_brotli :- Installing Brotli on your server: yum install pcre-devel cmake -y cd /usr/local/src git clone https://github.com/google/brotli.git cd brotli git checkout v1.0 ./configure-cmake make && make install Adding path for brotli dependencies files (run this commands one by one): grep "/usr/local/lib/" /etc/ld.so.conf || echo "/usr/local/lib/" >> /etc/ld.so.conf ldconfig Compile Apache with this flags from CWP Apache rebuild module WebServer Settings > Apache Re-Build then select the latest apache version “Select NEW Apache version:” and hit “Next” and add this flags to “Additional Configuration” and hit “Start Compiler in Background” --enable-brotli --with-brotli=/usr eg : After Apache is rebuilded create the config file : nano /usr/local/apache/conf.d/brotli.conf Now add this line to /usr/local/apache/conf.d/brotli.conf : LoadModule brotli_module modules/mod_brotli.so <IfModule mod_brotli.c> BrotliCompressionQuality 6 # To enable globally #AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon BrotliFilterNote Input brotli_input_info BrotliFilterNote Output brotli_output_info BrotliFilterNote Ratio brotli_ratio_info LogFormat '"%r" %{brotli_output_info}n/%{brotli_input_info}n (%{brotli_ratio_info}n%%)' brotli CustomLog "logs/brotli_log" brotli #Don't compress content which is already compressed SetEnvIfNoCase Request_URI \ \.(gif|jpe?g|png|swf|woff|woff2) no-brotli dont-vary #Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </IfModule> to enable brotli for all of your sites remove “#” before from AddOutputFilterByType ** BrotliCompressionQuality 6 for better compression you can select value 0-11 i’ll recommend value 6 After configuration restart Apache webserver : service httpd restart To enable brotli compression for your site add this config to .htaccess : <IfModule mod_brotli.c> AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon </IfModule> Now I understand the logic, I will give it a try. The other runs like a charm man, thank you so far.
December 3, 2023Dec 3 comment_335 Hello Sandeep, I followed your instructions, but when I install mod security, apache stops and gives the following error: apachectl[1315010]: httpd: Syntax error on line 514 of /usr/local/apache/conf/httpd.conf: Syntax error on line 9 of /usr/local/apache/conf.d/mod_security.conf: Cannot load modules/mod_security2.so into server: /usr/lib64/libbrotlidec.so.1: undefined symbol: _kBrotliPrefixCodeRanges I tried reinstalling mod security, as well as rebuilding and reinstalling apache but with no success. Any fix for this?
December 4, 2023Dec 4 Author comment_337 3 hours ago, vtheod said: Hello Sandeep, I followed your instructions, but when I install mod security, apache stops and gives the following error: apachectl[1315010]: httpd: Syntax error on line 514 of /usr/local/apache/conf/httpd.conf: Syntax error on line 9 of /usr/local/apache/conf.d/mod_security.conf: Cannot load modules/mod_security2.so into server: /usr/lib64/libbrotlidec.so.1: undefined symbol: _kBrotliPrefixCodeRanges I tried reinstalling mod security, as well as rebuilding and reinstalling apache but with no success. Any fix for this? it seems bug with mod security, brotli and mod sec can't run together if you need mod security then delete the brotli config : rm -rf /usr/local/apache/conf.d/brotli.conf && systemctl restart httpd if you need brotli remove mod security
December 4, 2023Dec 4 comment_340 Thank you, Sandeep. The strange is that in the past I set up a server (with your instructions in mysterydata) which works with brotli and mod sec together (you can check the screenshot). I'm sure there is a workaround for this.
December 4, 2023Dec 4 Author comment_341 4 minutes ago, vtheod said: Thank you, Sandeep. The strange is that in the past I set up a server (with your instructions in mysterydata) which works with brotli and mod sec together (you can check the screenshot). I'm sure there is a workaround for this. probably recent changes in brotli did the compatibility issue.
August 9Aug 9 comment_1067 I would love to improve my system, but many times old instructions not seem to work anymore because of wrong commands and modules that working slightly different or are being deprecated. Would it be useful to have brotli installed on a system that uses the 3 webservers, Nginx & Varnish & Apache and PHP-FPM activated, where apache is version 2.4.62 ? Since i am running alma linux 8.10 having kernel 6.10.3-1.el8.elrepo.x86_64 installed and mariadb 10.11.9, will these instructions work, or will it have me left again with a system that doesn't work anymore or just half.... If possible, can you rewrite the instructions so it will work with this setup ? Regards, Mike
August 13Aug 13 Author comment_1086 On 8/9/2024 at 6:07 PM, Dutch_Mike said: I would love to improve my system, but many times old instructions not seem to work anymore because of wrong commands and modules that working slightly different or are being deprecated. Would it be useful to have brotli installed on a system that uses the 3 webservers, Nginx & Varnish & Apache and PHP-FPM activated, where apache is version 2.4.62 ? Since i am running alma linux 8.10 having kernel 6.10.3-1.el8.elrepo.x86_64 installed and mariadb 10.11.9, will these instructions work, or will it have me left again with a system that doesn't work anymore or just half.... If possible, can you rewrite the instructions so it will work with this setup ? Regards, Mike you can build brotli in nginx only to get performance benefits with modern browsers
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now