• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Install Page Speed Google Nginx

bonny3

Basic Pleskian
Good evening,
I have a problem in operating the module PageSpeed with Nginx reverse.
I use
Plesk 12/05/30
Centos 6.7
Php 5.6.14 performed by FPM by Nginx
I installed the module via yum install mod-PageSpeed-beta-1.9.32.10-7423.x86_64
But it does not work properly.
I tried to add the string "pagespeed on" in nginx.conf but does not work
How can I do?
Thank you
Best regards
 
Hi bonny3,

please be sure, that nginx was compiled with the module "ngx_pagespeed". If you use the command "nginx -V", you will see the current nginx version, including the compiled options.

The current module could be downloaded at: https://github.com/pagespeed/ngx_pagespeed
( Please use at least the current compiling options as shown with the above command for compatibility reasons with Plesk and use for example the tutorial from Google to compile nginx from source: https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source )
 
Hi bonny3,

please be sure, that nginx was compiled with the module "ngx_pagespeed". If you use the command "nginx -V", you will see the current nginx version, including the compiled options.

The current module could be downloaded at: https://github.com/pagespeed/ngx_pagespeed
( Please use at least the current compiling options as shown with the above command for compatibility reasons with Plesk and use for example the tutorial from Google to compile nginx from source: https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source )

Good evening,
if i use plesk nginx reverse the procedure it is the same for this link? https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source
I currently use the version 1.9.4 of nginx plesk, but suggests the link to download the version 1.8.0, which must be installed?
I followed the installation from this link https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source
but using the command nginx -V it detects the version 1.9.4 and is not installed ngx_pagespeed.
I also watched this link https://github.com/pagespeed/ngx_pagespeed but there is no explanation of module installation.
What am I doing wrong?
Why is it so difficult to install it?
Thank you
 
Hi bonny3,

the package available in your repos is for apache only. If you use nginx standalone or nginx as proxy you should use pagespeed for nginx as UFHH01 already told you. Please check https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source again carefully. I used this several times and it works perfect! It doesn't matter in your case which nginx version you use but you should stay with 1.9.4 which is installed by default in plesk 12.5. Just make sure to use the same compiling options as plesk did it like UFHH01 already sayed too. To make it easier for you -> here you go:

1) install requirements for compiling if not already installed:
Code:
yum install gcc-c++ pcre-devel zlib-devel make unzip openssl-devel

2) download and extract pagespeed with psol:

Code:
cd
NPS_VERSION=1.9.32.10
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip
unzip release-${NPS_VERSION}-beta.zip
cd ngx_pagespeed-release-${NPS_VERSION}-beta/
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
tar -xzvf ${NPS_VERSION}.tar.gz  # extracts to psol/

3) check plesks nginx compiling options
Code:
nginx -V
you will get something like this
Code:
nginx version: nginx/1.9.4
configure arguments: --prefix=/usr/share --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --user=nginx --group=nginx --with-ipv6 --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/usr/share/passenger/ngx_http_passenger_module

4) now download your nginx version and compile it with pagespeed - you may receive an error with passenger_module. In this case just remove it from options. In the code below I have already remove this option... Please make sure to use the compiling options from step 3 instead of these ones but add --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta at the end!
Code:
cd
NGINX_VERSION=1.9.4
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
./configure --prefix=/usr/share --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --user=nginx --group=nginx --with-ipv6 --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta
make
make install

5) restart nginx
service nginx restart

6) place pagespeed options at the "Apache & Nginx settings" at the hosting settings inside your domain(s) control panel - maybe you want to add gzip aswell if you didn't use it already with a seperate gzip.conf or something like this...
Code:
pagespeed on;

# Needs to exist and be writable by nginx.  Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed_cache;
pagespeed EnableFilters combine_css,combine_javascript,combine_heads,convert_meta_tags,recompress_images;

# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
    add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }

gzip              on;
gzip_buffers      16 8k;
gzip_comp_level   1;
gzip_http_version 1.1;
gzip_min_length   10;
gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/x-font-ttf;
gzip_vary         on;
gzip_proxied      any; # Compression for all requests.
gzip_disable      "msie6";

location ~* \.(?:ico|css|js|gif|jpg|jpeg|png)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control “public”;
    try_files $uri @fallback;
}

7) you should be fine now. You can check /var/cache/ngx_pagespeed_cache if there are any files created after you open your site.

good luck!

//EDIT
i also suggest you to uninstall mod-pagespeed for apache with yum uninstall mod-PageSpeed-beta-1.9.32.10-7423.x86_64 before you use the instructions above.
 
Last edited:
Hi bonny3,

the package available in your repos is for apache only. If you use nginx standalone or nginx as proxy you should use pagespeed for nginx as UFHH01 already told you. Please check https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source again carefully. I used this several times and it works perfect! It doesn't matter in your case which nginx version you use but you should stay with 1.9.4 which is installed by default in plesk 12.5. Just make sure to use the same compiling options as plesk did it like UFHH01 already sayed too. To make it easier for you -> here you go:

1) install requirements for compiling if not already installed:
Code:
yum install gcc-c++ pcre-devel zlib-devel make unzip openssl-devel

2) download and extract pagespeed with psol:

Code:
cd
NPS_VERSION=1.9.32.10
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip
unzip release-${NPS_VERSION}-beta.zip
cd ngx_pagespeed-release-${NPS_VERSION}-beta/
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
tar -xzvf ${NPS_VERSION}.tar.gz  # extracts to psol/

3) check plesks nginx compiling options
Code:
nginx -V
you will get something like this
Code:
nginx version: nginx/1.9.4
configure arguments: --prefix=/usr/share --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --user=nginx --group=nginx --with-ipv6 --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/usr/share/passenger/ngx_http_passenger_module

4) now download your nginx version and compile it with pagespeed - you may receive an error with passenger_module. In this case just remove it from options. In the code below I have already remove this option... Please make sure to use the compiling options from step 3 instead of these ones but add --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta at the end!
Code:
cd
NGINX_VERSION=1.9.4
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
./configure --prefix=/usr/share --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --user=nginx --group=nginx --with-ipv6 --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta
make
make install

5) restart nginx
service nginx restart

6) place pagespeed options at the "Apache & Nginx settings" at the hosting settings inside your domain(s) control panel - maybe you want to add gzip aswell if you didn't use it already with a seperate gzip.conf or something like this...
Code:
pagespeed on;

# Needs to exist and be writable by nginx.  Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed_cache;
pagespeed EnableFilters combine_css,combine_javascript,combine_heads,convert_meta_tags,recompress_images;

# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
    add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }

gzip              on;
gzip_buffers      16 8k;
gzip_comp_level   1;
gzip_http_version 1.1;
gzip_min_length   10;
gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/x-font-ttf;
gzip_vary         on;
gzip_proxied      any; # Compression for all requests.
gzip_disable      "msie6";

location ~* \.(?:ico|css|js|gif|jpg|jpeg|png)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control “public”;
    try_files $uri @fallback;
}

7) you should be fine now. You can check /var/cache/ngx_pagespeed_cache if there are any files created after you open your site.

good luck!

//EDIT
i also suggest you to uninstall mod-pagespeed for apache with yum uninstall mod-PageSpeed-beta-1.9.32.10-7423.x86_64 before you use the instructions above.


Hi Ehrgeiz,
I followed his advice to the letter, but is not generated anything in the / var / cache / ngx_pagespeed_cache.
When I set the command nginz -V this is what comes out:
nginx version: nginx/1.9.4
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/share --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --user=nginx --group=nginx --with-ipv6 --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/root/ngx_pagespeed-release-1.9.32.10-beta

After following the installation commands I pasted this:


pagespeed on;

# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed_cache;
pagespeed EnableFilters combine_css,combine_javascript,combine_heads,convert_meta_tags,recompress_images;

# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }

gzip on;
gzip_buffers 16 8k;
gzip_comp_level 1;
gzip_http_version 1.1;
gzip_min_length 10;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/x-font-ttf;
gzip_vary on;
gzip_proxied any; # Compression for all requests.
gzip_disable "msie6";

location ~* \.(?:ico|css|js|gif|jpg|jpeg|png)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control “public”;
try_files $uri @fallback;

I saved inside the Plesk, Section Domain, Apache nginx & Settings for My Domain
as screenshots
2015-11-07_202719.jpg

I do not understand where I'm wrong.
is possible to do a test to see if it is really installed or enabled ngx_pagespeed ?
Thanks you Very Much
 
Hi bonny3,

i think your output of nginx -V looks fine... You can test it for example with Wappalyzer or check the HTTP headers (I'm not sure atm if you find it there) but when nothing is created in the cache folder i think it doesn't work already.
since it shows the module in nginx -V i think you didn't received any errors while make or make install - correct? You can see the cache folder? Just to be sure set owner and group to the nginx user with chown nginx:nginx /var/cache/ngx_pagespeed_cache and chmod 777 and check again.

You could also try to reconfigure your domains with /usr/local/psa/admin/bin/httpdmng --reconfigure-all and check the nginx conf files inside /var/www/vhosts/YOURDOMAIN/conf/ if you can see your changes there.

And just to complete my last post: the last 5 lines

Code:
location ~* \.(?:ico|css|js|gif|jpg|jpeg|png)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control “public”;
try_files $uri @fallback;

are just to tell a client to cache pictures for 30 days. Maybe you don't want / need this!

If you can't get it to work you can try to check the console. Follow the instructions here.

Hope it helps!
 
Hi bonny3,

i think your output of nginx -V looks fine... You can test it for example with Wappalyzer or check the HTTP headers (I'm not sure atm if you find it there) but when nothing is created in the cache folder i think it doesn't work already.
since it shows the module in nginx -V i think you didn't received any errors while make or make install - correct? You can see the cache folder? Just to be sure set owner and group to the nginx user with chown nginx:nginx /var/cache/ngx_pagespeed_cache and chmod 777 and check again.

You could also try to reconfigure your domains with /usr/local/psa/admin/bin/httpdmng --reconfigure-all and check the nginx conf files inside /var/www/vhosts/YOURDOMAIN/conf/ if you can see your changes there.

And just to complete my last post: the last 5 lines

Code:
location ~* \.(?:ico|css|js|gif|jpg|jpeg|png)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control “public”;
try_files $uri @fallback;

are just to tell a client to cache pictures for 30 days. Maybe you don't want / need this!

If you can't get it to work you can try to check the console. Follow the instructions here.

Hope it helps!

Hello,
I solved the problem!!
Your guide is perfect the only thing you have to integrate lil command
## Mkdir / var / cache / ngx_pagespeed_cache
## Chown nginx: / var / cache / ngx_pagespeed_cache
to give permissions to the folder, then everything works fine: -D
Thanks a lot
see you soon
 
@bonny3 and @ehrgeiz,

There are some problems with your installations, in the sense that

- some config settings are "double", and/or
- some config settings are wrongly placed, and/or
- compilation of nginx is not quite as it should be, and/or
- future issues can be expected.

First of all, note that the nginx pagespeed module is somewhat unstable. It can break the whole Apache + Nginx stack, due to performance issues (i.e. overloads) and/or buggy code.

Be aware that you have to optimize the Apache + Nginx stack in Plesk manually, in order to minimize the risk of the pagespeed module resulting in errors.

With respect to the "double config settings", the following.

Note that one does not necessarily has to define the gzip and/or header config settings, that can be arranged by the pagespeed settings.

In fact, when using pagespeed settings to determine compression levels and/or set headers, these pagespeed will often prevail (i.e. dominate other settings) or even break the settings in the normal nginx.conf or *.conf files.

When using the pagespeed module, it is adviceable to configure settings with the pagespeed module (and not normal config files), as far as possible.

With respect to the wrong placement of config settings, the following.

Bonny3 stated:
I saved inside the Plesk, Section Domain, Apache nginx & Settings for My Domain as screenshots

It is NOT the correct place for

- the directive "pagespeed on",
- the pagespeed related location directives,

and NOT the preferred place for gzip related directives.

The proper way to do this is to create a custom config file, by preference located in the /etc/nginx/plesk.conf.d directory (the /etc/nginx/conf.d directory will also work).

After all, the before mentioned directives are server-wide directives, that should be applied to the whole Nginx server.

The actual activation of specific pagespeed filters and similar directives CAN be placed in the domain and subdomain custom config files.

With respect to the compilation of nginx, the following.

Note that the compilation of the pagespeed module into Nginx is easy and certainly, one has to

- use the proper prefixes and file paths,
- be aware that one does overwrite the Plesk provided Nginx packages and standard config settings,

and the above implies that reverting a erroneous Nginx + pagespeed stack can become rather problematic.

Remember that the pagespeed module is still experimental of nature (and many well-known bugs do exist).

Also note that it is possible (and better) to compile some of the standard pagespeed file/config paths into Nginx, but that requires some tweaking (of source code).

With respect to the future issues, the following.

Note that the current pagespeed module for Nginx is in beta, "experimental" as Google calls it.

Any future alpha release will again be followed by a stable release and, each time a release occurs, one has to recompile AND adjust all config settings.

In short, the current pagespeed module is not the best choice.

Also note that the current pagespeed module consists of various components, that are already available in existing (and often more stable) Nginx modules (third-party modules).

Most of the components in the pagespeed module are not working properly and are underperforming, when compared to before mentioned (stable) existing Nginx modules.

Another subset of components in the pagespeed module are not really used or not really usable, in general scenario´s of webhosting.

In short, the current pagespeed module is an overload of new and old components for Nginx, with the factual danger of undermining performance of Nginx.

Finally, the irony is that the pagespeed module is not really valuable in most of the common implementations of Nginx: if and only if Nginx is used as a pure webserver (and that is not the case in Plesk installations), pagespeed becomes a somewhat valuable module for Nginx.

In conclusion, rethink, before adding the pagespeed module to Nginx.

And, if one really does want to (automatically)

- minimify JS and CSS: use perl-based scripts with Nginx (requires perl module for Nginx) OR other scripts (bash, python, perl etc.) with a crontab,
- minimify images: use jpegcrush, jpegtran etc with a crontab,
- defer JS: alter the html and/or php templates, instead of optimizing afterwards (i.e. remove suboptimal code, instead of working around this issue with pagespeed)

and so on.

Regards....
 
@bonny3 and @ehrgeiz,

There are some problems with your installations, in the sense that

- some config settings are "double", and/or
- some config settings are wrongly placed, and/or
- compilation of nginx is not quite as it should be, and/or
- future issues can be expected.

First of all, note that the nginx pagespeed module is somewhat unstable. It can break the whole Apache + Nginx stack, due to performance issues (i.e. overloads) and/or buggy code.

Be aware that you have to optimize the Apache + Nginx stack in Plesk manually, in order to minimize the risk of the pagespeed module resulting in errors.

With respect to the "double config settings", the following.

Note that one does not necessarily has to define the gzip and/or header config settings, that can be arranged by the pagespeed settings.

In fact, when using pagespeed settings to determine compression levels and/or set headers, these pagespeed will often prevail (i.e. dominate other settings) or even break the settings in the normal nginx.conf or *.conf files.

When using the pagespeed module, it is adviceable to configure settings with the pagespeed module (and not normal config files), as far as possible.

With respect to the wrong placement of config settings, the following.

Bonny3 stated:

It is NOT the correct place for

- the directive "pagespeed on",
- the pagespeed related location directives,

and NOT the preferred place for gzip related directives.

The proper way to do this is to create a custom config file, by preference located in the /etc/nginx/plesk.conf.d directory (the /etc/nginx/conf.d directory will also work).

After all, the before mentioned directives are server-wide directives, that should be applied to the whole Nginx server.

The actual activation of specific pagespeed filters and similar directives CAN be placed in the domain and subdomain custom config files.

With respect to the compilation of nginx, the following.

Note that the compilation of the pagespeed module into Nginx is easy and certainly, one has to

- use the proper prefixes and file paths,
- be aware that one does overwrite the Plesk provided Nginx packages and standard config settings,

and the above implies that reverting a erroneous Nginx + pagespeed stack can become rather problematic.

Remember that the pagespeed module is still experimental of nature (and many well-known bugs do exist).

Also note that it is possible (and better) to compile some of the standard pagespeed file/config paths into Nginx, but that requires some tweaking (of source code).

With respect to the future issues, the following.

Note that the current pagespeed module for Nginx is in beta, "experimental" as Google calls it.

Any future alpha release will again be followed by a stable release and, each time a release occurs, one has to recompile AND adjust all config settings.

In short, the current pagespeed module is not the best choice.

Also note that the current pagespeed module consists of various components, that are already available in existing (and often more stable) Nginx modules (third-party modules).

Most of the components in the pagespeed module are not working properly and are underperforming, when compared to before mentioned (stable) existing Nginx modules.

Another subset of components in the pagespeed module are not really used or not really usable, in general scenario´s of webhosting.

In short, the current pagespeed module is an overload of new and old components for Nginx, with the factual danger of undermining performance of Nginx.

Finally, the irony is that the pagespeed module is not really valuable in most of the common implementations of Nginx: if and only if Nginx is used as a pure webserver (and that is not the case in Plesk installations), pagespeed becomes a somewhat valuable module for Nginx.

In conclusion, rethink, before adding the pagespeed module to Nginx.

And, if one really does want to (automatically)

- minimify JS and CSS: use perl-based scripts with Nginx (requires perl module for Nginx) OR other scripts (bash, python, perl etc.) with a crontab,
- minimify images: use jpegcrush, jpegtran etc with a crontab,
- defer JS: alter the html and/or php templates, instead of optimizing afterwards (i.e. remove suboptimal code, instead of working around this issue with pagespeed)

and so on.

Regards....

After installing the module works very well and I have no problem.
Then PageSpeed can always to improve;-)
Best regards
 
@bonny3,

Try to run a siege command from the command line, while having a look at resource usage levels (with top or any other command line tool) and you will see that pagespeed module chokes the server and, when simulating a DDOS and/or Brute Force attack, the pagespeed module will often break the server.

The only method to prevent any issues with pagespeed module is to make minimal use of all pagespeed directives.

And that just makes a big question mark of the value added by pagespeed module.

In addition, have a look on the internet or even consult the Google developers, in order to establish the potential problems of activating the pagespeed module.

It is just an advice, feel free to do what you want.

A final and fairly relevant note: you are aware of the fact that any future update of Plesk Nginx packages will overwrite your custom compilations of Nginx (and, therefore, that any custom directive, including the pagespeed directives, will break the Nginx server)?

Regards.....
 
Hi trialotto!

thanks for the correction and of cause you are right with the config! Didn't get that at first.

Regarding the problems you described:
Also note that the current pagespeed module consists of various components, that are already available in existing (and often more stable) Nginx modules (third-party modules).
Can you tell us some alternatives to pagespeed? I think in nginx every "module" have to compile with source to work properly. This is the same problem with HTTP2 since SPDY will be "disabled" 2016 and NGINX supports HTTP2 if it is compiled with -with-http_v2_module since 1.9.5 and plesk currently deploys 1.9.4. Also SPDY has to be enabled on this way so we have to compile it by our own or just stuck without SPDY and HTTPD2 wich is not in all cases a option.

It is clear that future updates of NGINX via plesk will break the config. Just don't understand why to stay with 1.9.4 when 1.9.5 was released when Plesk 12.5 comes out. It should be easy to give costumers the option to use SPDY or HTTP2 now.

Finally, the irony is that the pagespeed module is not really valuable in most of the common implementations of Nginx: if and only if Nginx is used as a pure webserver (and that is not the case in Plesk installations), pagespeed becomes a somewhat valuable module for Nginx.
This is also correct. What is the "best practise" solution for plesks nginx proxy + apache configuration?
 
Last edited:
@ehrgeiz,

Interesting response.

You did some proper research, or you obviously have some experience with Nginx. Nice!

I will tackle your questions and remarks, including some relevant context.

Can you tell us some alternatives to pagespeed? I think in nginx every "module" have to compile with source to work properly. This is the same problem with HTTP2 since SPDY will be "disabled" 2016 and NGINX supports HTTP2 if it is compiled with -with-http_v2_module since 1.9.5 and plesk currently deploys 1.9.4. Also SPDY has to be enabled on this way so we have to compile it by our own or just stuck without SPDY and HTTPD2 wich is not in all cases a option.

With respect to the alternatives for pagespeed, I will return to that question at the end of this post.

With respect to the Nginx 1.9.5 version, I already asked Odin Team why 1.9.4 has been chosen (no answer yet).

I am personally testing the use of 1.9.5 with httpv2 module, since it should be the case that Plesk can run with that Nginx version (without any problems).

It is clear that future updates of NGINX via plesk will break the config. Just don't understand why to stay with 1.9.4 when 1.9.5 was released when Plesk 12.5 comes out. It should be easy to give costumers the option to use SPDY or HTTP2 now.

Ehm, it is EITHER SPDY OR Httpv2, a combination is not really possible and/or desirable.

The choice for SPDY implementation by Odin Team is rather logical, since implementation of (only) Httpv2 can have it´s drawbacks. Nginx should run with Http2 without problems, but that does not imply that serving of web pages is without problems, given the fact that Http2 is not yet the standard.

This is also correct. What is the "best practise" solution for plesks nginx proxy + apache configuration?

That really depends on the intended purpose of the Nginx server.

If Nginx is only used for static file serving, one can simply use the Nginx 1.9.4 version as provided by Odin, with some (extensive and appropriate) tweaking of Nginx config settings.

If Nginx is used for hardening security (yes, a valid solution, intended to keep specific traffic out of Apache), the above also implies.

If Nginx is used as a proper web server, it is best to create a stand-alone Nginx server (without all the unnecessary Apache and/or Plesk stuff). Note: this is advanced usage of Nginx.

Note that Nginx can also be easily configured to function as a (internal or external) CDN, but I will not go into this possibility.

If Nginx is used as a proxy for Apache, in order to speed up the process and/or dynamic transformation of serving web pages, one can best implement:

a) Apache + Redis Cache OR Apache + Memcached (note: Redis is preferred over Memcached), PLUS

b) Nginx with FastCGI Cache + Perl module + some custom modules, allowing for (amongst others):

- basic minification (CSS and JS) via a Perl script,
- image transformation, for instance creating WebP (lossy and lossless compressed) images via a Perl script, calling the cwebp and dwebp libraries,
- bandwith throttling (via a third-party Nginx module)

and so on.

In essence, everything pagespeed module can do, can also be achieved with other modules.

The advantages of not using pagespeed are:

- a better grip on set-up, with the associated advantage of regular updates on the individual packages AND the freedom of choice of those packages,
- more flexible processes and more options to configure those processes

and so on.

For instance, one does not really want image transformation at request time (i.e. no waste of resources), one prefers the creation of transformed images via a cron process, WITH Nginx serving the already existing images and only transforming those images that are not transformed yet.

Note that pagespeed module includes a similar process, but only creates transformations for files that are requested, hence limiting the store of transformed images.

Taking the transformation into control (via a cron process) will augment the store of transformed images, hence reducing the performance issues at request time AND with the added advantage that you can schedule transformation in periods of low traffic (as opposed to request time transformation, i.e. transformation in periods that traffic actually occurs).

This is just one example, many other examples can be given.

In conclusion, before configuring Nginx and/or adding Nginx modules, one has to review the purpose of the Nginx server AND the process of traffic AND the inherent bottlenecks.

In my humble opinion, "lean" configuration is best, as intended by Nginx and reflected in the nature of Nginx.

In my humble opinion, one should only add a Perl module to Nginx, in order to make use of many functions, that are defined by customizable (!) scripts.

Regards....

PS I am developing a Nginx setup that is intended to get better PageSpeed/Yslow scores (i.e. it is intended to enhance webserving), feel free to join the project.
 
Hi trialotto,

i got some basic skills and did a lot of research in the last days since I have to install a new webserver for my company (VPS with E5-2620 v2 (6vCores), 32GB RAM, 140GB space on SSD (gross) with CentOS 7 with Apache 2.4.6 and MariaDB 5.5.44 managed by Plesk 12.5). The old Systems are dedicated with E31220 (4 Cores), 12GB RAM, 1TB consumer HDD with CentOS 6 with Apache 2.2.15 and MySQL 5.1 managed by Plesk 12.5. (I want to get database and data on SSD and of cause more RAM since the old server begins to use SWAP after some uptime - so this new system was the only choice located near to our costumers.)

Ehm, it is EITHER SPDY OR Httpv2, a combination is not really possible and/or desirable.

The choice for SPDY implementation by Odin Team is rather logical, since implementation of (only) Httpv2 can have it´s drawbacks. Nginx should run with Http2 without problems, but that does not imply that serving of web pages is without problems, given the fact that Http2 is not yet the standard.
I know - sorry for misunderstanding. I mean it should be possible to include http2 module in Odins nginx version and a simple checkbox in admin to activate it or not. I already installed http2 but you are right - I don't want to handel "emergency calls" when plesk updates itselfs with a new nginx version so I prefer to stay with 1.9.4 for the moment.

At this point I also miss a place to setup more detailed HTTPS configurations for ciphers and so on - but okay... It is not hard to edit the custom domain template for nginx.


Altogether I just want to serve static content by nginx and currently my config on the new system is near to default. Refer to plesk documentation /etc/nginx/nginx.conf is the default configuration. Just wondering about:

Code:
#user  nginx;
worker_processes  6;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

some lines are commented out but still in use like the log and user line(s).

b) Nginx with FastCGI Cache + Perl module + some custom modules, allowing for (amongst others):
For FastCGI Cache you also need to compile nginx or? Same "problem" as with pagespeed.

PS: sure. just drop me a pm and let me know more.
 
Last edited:
@ehrgeiz

Before sending you a mail (i.e. starting a conversation), some general comments, in order to allow other forum members to read them.

I already installed http2 but you are right - I don't want to handel "emergency calls" when plesk updates itselfs with a new nginx version so I prefer to stay with 1.9.4 for the moment.

No need to worry. Just leave some directives for "other" modules (i.e. modules not compiled in the standard Plesk Nginx) out of the config files.

At this point I also miss a place to setup more detailed HTTPS configurations for ciphers and so on - but okay... It is not hard to edit the custom domain template for nginx.

It is not necessary to edit domain templates.

In the directory /etc/nginx/conf.d, there is a file called ssl.conf (on Plesk 12.5.30) and this config file contains some https related directives.

If the desire or need to customize config settings ever exists, just add a custom config file (for example, ssl-custom.conf) in the same directory.

The custom conf settings can be tested and loaded by the command: nginx -t && service nginx reload (if I recall it correctly).

Just wondering about:

Code:
#user nginx;
worker_processes 6;

#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
some lines are commented out but still in use like the log and user line(s).

No need to worry here, just leave it as is.

If the need to get debug information ever exists, simply uncomment the lines and do the "nginx -t && service nginx reload" command.

Note that the lines above are concerning debug/log information on the server level, which is not that useful most of the times.

Sometimes it is more convenient to allow for an additional log level verbosity on the domain or subdomain level.

For FastCGI Cache you also need to compile nginx or? Same "problem" as with pagespeed.

No, the FastCGI module is (more or less) included in the standard Nginx package, provided by Odin.

Again, no worries there.

Regards....
 
Hi trialotto,

if I leave the http2 directives out of the config files or in my case out of domain template I have to use own config files like ssl-custom.conf but these will be executed also on system or deamon start and will briks system when nginx has been updated by Plesk. So what's the matter? Sorry I didn't get it... Also in my oppinion i can't use the SSL options in this file (i.e. there is no ssl.conf) - nginx won't start.

About the logs. The question is: why there are log files under /var/log/nginx/ when this lines are "disabled" with #. There should be another conf but don't know where. It was just interesting for me.
 
hello

i have error

nginx: [emerg] "location" directive is not allowed here in /etc/nginx/conf.d/gzip.conf:9
nginx: configuration file /etc/nginx/nginx.conf test failed

on start

file gzip.conf

pagespeed on;

# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed_cache;
pagespeed EnableFilters combine_css,combine_javascript,combine_heads,convert_meta_tags,recompress_images;

# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }

gzip on;
gzip_buffers 16 8k;
gzip_comp_level 1;
gzip_http_version 1.1;
gzip_min_length 10;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/x-font-ttf;
gzip_vary on;
gzip_proxied any; # Compression for all requests.
gzip_disable "msie6";

location ~* \.(?:ico|css|js|gif|jpg|jpeg|png)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control “public”;
try_files $uri @fallback;
}
 
[root@ns3 ~]# nginx -V
nginx version: nginx/1.9.4
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/share --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/ng
inx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --http-clien
t-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --
http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --user=nginx --group=nginx --with-ipv6 --with-f
ile-aio --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_modu
le --with-http_stub_status_module --add-module=/root/ngx_pagespeed-release-1.9.32.10-beta
[root@ns3 ~]#
 
Back
Top