• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Dukemaster

Regular Pleskian
Hi at all,
something drives me mad since weeks, especially since I use only nginx with PHP71-FPM nginx.
Half year ago as I used like most users Apache with Nginx Reverse and PHP71-FPM apache, but this is unimportant any longer, perhaps only for the possibility hosting customers who wnat to use mainly Apache.

1.I activated ZLIB compression in the PHP.INI of the handler FPM71 which I use.
2. I also use GZIP either in both variants: Now with Only Nginx and also in former times with Nginx as ReverseProxy.
3. I use a community software Woltlab which has an option for GZIP. This is recommend and used by most Woltlab customers. It's activated since years. In my point of view it's not additional, it's only related to the normal server-side GZIP, but I'm not sure. The WBB-Support recommend compression-level 1. But in Nginx settings I use 9. Perhaps this could be contra-productive oor using both a basic misconfiguration?

Most important question at all is: Is it possible and better to use both variants of compression (zlib and gzip)?
Would would You suggest to do?


(and I've really read tons of documentations from all kinds of sources here and on internet)
 
As far as I know, usually, compress data using PHP is not recommended, as it is quite slow.
GZIP provides good performance and compression, but now there is a more advanced and modern compression technology - read about brotli :)
 
Thanks for all comments. I stumpled upon this magic feature so often on internet last months since I look closer to configuration tasks. OK. Let's search for UFHH01, brotli first here and if no results also in google...
 
Last edited:
Hi @ all,

"brotli" has to be built in with nginx on your server, so basically, you should follow for example:


and when you reached step 5, you will need for example:

Code:
cd /usr/share/nginx/modules
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli/
git submodule update --init --recursive

... and you would then continue with the tutorial => configure/make/make install

... with the only difference, that you need an additional configure - option:
Code:
--add-module=/usr/share/nginx/modules/ngx_brotli


For the additional "brotli" configuration, you would modify "/etc/nginx/nginx.conf" with for example:
Code:
# BEGIN Google brotli - definitions, tuned by UFHH01
    brotli on;
    brotli_static on;
    brotli_types text/html text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/vnd.microsoft.icon image/bmp image/svg+xml;
    brotli_comp_level 8;
# END Google brotli - definitions, tuned by UFHH01
and for "gzip" - compression, you could add for example:
Code:
# BEGIN gzip - Definitions, tuned by UFHH01
    gzip_static on;
    gzip on;
    gzip_proxied any;
    gzip_http_version 1.1;
    gzip_min_length 100;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_types audio/wav audio/ogg font/opentype text/css text/javascript text/plain text/richtext text/x-component text/x-js text/xml text/xsd text/xsl font/opentypeapplication/font-woff application/atom+xml application/font-woff2 application/javascript application/java application/json application/msword application/pdf application/xhtml+xml application/xml application/xml+rss image/bmp image/tiff image/svg+xml image/webp image/x-icon application/vnd.ms-access application/vnd.ms-excel application/vnd.ms-fontobject application/vnd.ms-opentype application/vnd.ms-powerpoint application/vnd.ms-project application/vnd.ms-write application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text application/x-font-ttf application/x-font-opentype application/x-font-otf application/x-javascript application/x-msdownload application/x-shockwave-flash application/x-web-app-manifest+json; # Disable gzip for certain browsers. gzip_disable “MSIE [1-6].(?!.*SV1)”;
# END gzip - Definitions, tuned by UFHH01
 
Hi @ all,

"brotli" has to be built in with nginx on your server, so basically, you should follow for example:


and when you reached step 5, you will need for example:

Code:
cd /usr/share/nginx/modules
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli/
git submodule update --init --recursive

... and you would then continue with the tutorial => configure/make/make install

... with the only difference, that you need an additional configure - option:
Code:
--add-module=/usr/share/nginx/modules/ngx_brotli


For the additional "brotli" configuration, you would modify "/etc/nginx/nginx.conf" with for example:
Code:
# BEGIN Google brotli - definitions, tuned by UFHH01
    brotli on;
    brotli_static on;
    brotli_types text/html text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/vnd.microsoft.icon image/bmp image/svg+xml;
    brotli_comp_level 8;
# END Google brotli - definitions, tuned by UFHH01
and for "gzip" - compression, you could add for example:
Code:
# BEGIN gzip - Definitions, tuned by UFHH01
    gzip_static on;
    gzip on;
    gzip_proxied any;
    gzip_http_version 1.1;
    gzip_min_length 100;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_types audio/wav audio/ogg font/opentype text/css text/javascript text/plain text/richtext text/x-component text/x-js text/xml text/xsd text/xsl font/opentypeapplication/font-woff application/atom+xml application/font-woff2 application/javascript application/java application/json application/msword application/pdf application/xhtml+xml application/xml application/xml+rss image/bmp image/tiff image/svg+xml image/webp image/x-icon application/vnd.ms-access application/vnd.ms-excel application/vnd.ms-fontobject application/vnd.ms-opentype application/vnd.ms-powerpoint application/vnd.ms-project application/vnd.ms-write application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text application/x-font-ttf application/x-font-opentype application/x-font-otf application/x-javascript application/x-msdownload application/x-shockwave-flash application/x-web-app-manifest+json; # Disable gzip for certain browsers. gzip_disable “MSIE [1-6].(?!.*SV1)”;
# END gzip - Definitions, tuned by UFHH01

It might make sense to add these steps to your awesome nginx + pagespeed guide and expand the optimal nginx setting.

As plesk now offer pagespeed extensions for apache will this cause any problems with nginx?
 
I was informed that selve compiled nginx + pagespeed and standarx plask apache + pagespeed could cause js problems.

Activation of apache pagespeed is very simple, but is there a easy removal guide as well?
 
Last edited:
Hi Rar9,

I was informed that nginx + pagespeed and apache + pagespeed could cause js problems.
I can't judge/comment about your sources, but you should consider to inform yourself, that the Plesk Extension "Google PageSpeed Insights" is not a "pagespeed module for apache". ;)
 
But wi
Hi Rar9,


I can't judge/comment about your sources, but you should consider to inform yourself, that the Plesk Extension "Google PageSpeed Insights" is not a "pagespeed module for apache". ;)
But this Google PageSpeed insights extension allows you to:

Install PageSpeed Apache Module
 
Hi Rar9,

yes, this is an option, but has got nothing to do with Plesk and it's components/extensions. How you use and modify the pagespeed modules ( apache+nginx, apache only, nginx only ) is a unique user choice and is out of scope from Plesk.
 
Hi @UFHH01 ,
wooow, if had known to install brotli together with the other modules it would be easier. I just compiled the new nginx again with brotli (running configure, make, make install the second time). But again no errors. It worked.
For the additional "brotli" configuration, you would modify "/etc/nginx/nginx.conf" with for example:
To this tutorial with brotli here ^^. Do you mean to replace the whole content in /etc/nginx/ngingx.conf with these few brotli lines (tuned by UFHH01, smile). NO, or?
Please, at which place shall I place your code. Now, by being successful running new nginx release I won't throw it away by stupid mistakes.

THANKS for this amazing tutorial work for "NGINX - The Beast".
 
Hi Dukemaster,

Please, at which place shall I place your code.
Pls. feel free to add such modifications inside the "http" - section:
Code:
http {

...
...

}


Additional ( personal ) information:
I always place my additional code at the very end, so that it is easier to investigate issues/errors/problems and I always add "information lines", as the ones I provided above, to make it easier to find modifications. ;)
 
Hi @UFHH01 ,
thanks for your help. The new gzip configuration by You I will also include there.
But I have a problem now with some files in /etc/nginx/conf.d because there is already a gzip.conf. Plus ssl.conf, 001_own_additional_hsts_.conf, files - and a new is there "phusion-passenger.conf".

- I think gzip.conf I can delete in ../conf.d/ for sure (to avoid double configuration).

- aa500_psa_tweaks.conf + zz010_psa_nginx.conf + ssl.conf are okay for sure.

- phusion-passenger.conf has only one little configuration line (passenger_root /usr/share/passenger/phusion_passenger/locations.ini; ) could be also okay?
It has nothing to do with the other deleted passenger.conf during nginx compilation/installation (because it was another target/path, not in conf.d as I remember)

- 001_own_additional_hsts_.conf should be also okay, for HSTS and param and preload. It's the only one I'm unsure. In my case it has the following content:
Code:
map $scheme $hsts_header {
    https 'max-age=15768000; preload';
}
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:50m;
ssl_session_cache shared:ssl_session_cache:10m;
ssl_dhparam /etc/dhparam/dhparam4096.pem;
ssl_ecdh_curve secp521r1:secp384r1:prime256v1;

Greets
 
Last edited:
Thanks for all - Oh, I just found out by nginx -t
Code:
nginx -t
nginx: [emerg] unknown directive "brotli" in /etc/nginx/nginx.conf:43
nginx: configuration file /etc/nginx/nginx.conf test failed
Line 43 is :
brotli on;

But brotli exists in /usr/share/nginx/modules/ngx_brotli and I made the little additional tutorial exactly how it is and did .configure + make + make install without any errors again.
 
Last edited:
Hi Dukemaster,

pls. what is the output of
Code:
nginx -V

Your error message states clear, that "brotli" is not known and is therefore not compiled in.
 
Back
Top