• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • 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.

Input How to compile NGINX with additional modules ( pagespeed / cache_purge / headers-more / and others )

I noticed that there is an updated nginx 1.13.4 and new ngx_pagespeed-1.12.34.2-stable version.

When I change these from the Config setup and MAKE I get this error:


Use the available Release binaries? [Y/n] y
./configure: 158: /usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-stable/config: [[: not found
./configure: 158: /usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-stable/config: y: not found
mod_pagespeed_dir=/usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-stable/psol/include
build_from_source=false

....


/usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-stable/src/ngx_pagespeed.cc
/usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-stable/src/ngx_pagespeed.cc: In function ‘ngx_int_t net_instaweb::{anonymous}: pss_preaccess_handler(ngx_http_request_t*)’:
/usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-stable/src/ngx_pagespeed.cc:3011:31: error: ‘ngx_http_core_try_files_phase’ was not declared in this scope
while (ph[i + 1].checker != ngx_http_core_try_files_phase &&
^
objs/Makefile:2029: recipe for target 'objs/addon/src/ngx_pagespeed.o' failed
make[1]: *** [objs/addon/src/ngx_pagespeed.o] Error 1
make[1]: Leaving directory '/root/addons/nginx/nginx-1.13.4'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

What am I doing wrong?
 
Last edited:
Hi Rar9,

pls. be aware, that with my tutorial, I suggest to use different releases. If you use different versions, I can't guarantee that this will not lead to issues/errors/problems, as they are either not tested by me, or they are still in development and need adjustments/corrections in order to work as expected.


For your current error message, pls. see:

 
Hi @UFHH01 Last night I deleted both directories (nginx-1.13.2 and content of usr/share/nginx/modules), then also whole Nginx over Plesk updates/upgrades panel. Afterwards I reinstalled nginx over the same site, made all patches, micro-updates, and reinstalled the whole new nginx release again with ngx_pagespeed module.
Successful nginx-1.13.2 with pagespeed-1.12.34.2-stable like yesterday. But with the same problem.
Is it normal that the other 4 modules ngx_cache_purge-2.3, ngx_coolkit-0.2, and more are also not visible by command
Code:
nginx -V
?
Why is brotli not compiled with nginx? What can I do or change?

Greets
 
Hi Dukemaster,

I'm sorry, but how do you expect me to investigate your issue, if you don't provide entries from your command line?

Is it normal that the other 4 modules ngx_cache_purge-2.3, ngx_coolkit-0.2, and more are also not visible by command
Code:
nginx -V
?
No, it is not "normal". After a successfull compilation, finished with "make install", the compiled nginx should have been replaced with your "old" one and you can certainly see the compiling options with the "nginx -V" command.
 
Hi @UFHH01 Problem successfully solved.
I used a mix of the original "brotli-documentation" by PiotrSikora in Github and Your syntax.
So, BROTLI and ALL other modules are now registered and compiled with new nginx-1.13.2 release by writing the --with-xyz and --add-xyz command in one single line only seperated by a space.
Therefor I recommend to write ALL module-items without slashes in one single line, ONLY seperated by one space between each other, like example in the box below.

Thanks a lot for your great tutorial. You make me and many others happy. Honors to You and to the great PLESK SOFWARE and SUPPORT-COMMUNITY.
:):):) I'm happy to solve my problem by thinking in another way.

Syntax and solution
Code:
./configure --prefix=/etc/nginx --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-debug --with-file-aio --with-google_perftools_module --with-ipv6  --with-mail --with-mail_ssl_module --with-threads --with-select_module --with-stream --with-stream_ssl_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-openssl=/usr/src/openssl-1.0.2l --with-http_v2_module --with-http_xslt_module --with-poll_module --add-module=/usr/share/passenger/ngx_http_passenger_module --add-module=/usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-stable --add-module=/usr/share/nginx/modules/ngx_brotli --add-module=/usr/share/nginx/modules/ngx_cache_purge-2.3 --add-module=/usr/share/nginx/modules/ngx_slowfs_cache-1.10 --add-module=/usr/share/nginx/modules/ngx_coolkit-0.2 --add-module=/usr/share/nginx/modules/ngx_headers-more-0.32


Result

Code:
root@server:~/addons/nginx/nginx-1.13.2# nginx -V
nginx version: nginx/1.13.2
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
built with OpenSSL 1.0.2l  25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --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-debug --with-file-aio --with-google_perftools_module --with-ipv6 --with-mail --with-mail_ssl_module --with-threads --with-select_module --with-stream --with-stream_ssl_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-openssl=/usr/src/openssl-1.0.2l --with-http_v2_module --with-http_xslt_module --with-poll_module --add-module=/usr/share/passenger/ngx_http_passenger_module --add-module=/usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-stable --add-module=/usr/share/nginx/modules/ngx_brotli --add-module=/usr/share/nginx/modules/ngx_cache_purge-2.3 --add-module=/usr/share/nginx/modules/ngx_slowfs_cache-1.10 --add-module=/usr/share/nginx/modules/ngx_coolkit-0.2 --add-module=/usr/share/nginx/modules/ngx_headers-more-0.32

Greets to all of You
 
Last edited:
Hi @UFHH01,
You wrote this amazing tutorial and helped me and others in any questions. Now I have the module correctly installed. But the goal to archive would be to run it.
I hope I didn't misunderstood the pagespeed manuals, that it is necessary to make a few steps to do it.
For the reason I use it only with nginx, they write here
I have a problem with this.
Code:
 In Apache PageSpeed is enabled automatically when you install the module while in Nginx you need to add several lines to your nginx.conf. In every server block where PageSpeed is enabled add:

pagespeed on;

# Needs to exist and be writable by nginx.  Use tmpfs for best performance.
pagespeed FileCachePath /var/ngx_pagespeed_cache;

# 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$" { }
You told me somewhere else that location tasks shouldn't insert in server http block, or in other words in /etc/nginx/nginx.conf.
From my point of view I would write the first two commands in nginx.conf. Here my nginx.conf
Code:
#user  nginx;
worker_processes  1;

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

#pid        /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;

    # 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

    # 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

    pagespeed on;

    # Needs to exist and be writable by nginx.  Use tmpfs for best performance.
    pagespeed FileCachePath /var/ngx_pagespeed_cache;

}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

The rest of code in vhost template under additional nginx directives? I haven't done this step, I wanted to wait what do you recommend?
Code:
# 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$" { }
Am I right or totally wrong?
Can you please help me these steps.
Perhaps also with the vary and cache control headers.
It seems to configure only a few, but important things.

For the tmpfs recommendation I found an interesting solution by @IgorG written his year. Usually I do not change my filesystem, except one thing by installing whole OS with Plesk I expand /var/ by 750 GB. This is necessary on 1and1 servers by default-images.
Perhaps I can do this tmpfs on RAM later, after a period of time, hope it is not strictly necessary.
All the other interesting things like statistics and pagespeed console are a nice present.
But I only want to run pagespeed in basic configuration and see how and if it works.

Thanks and lots of greets
 
Last edited:
Hi Dukemaster,

pls. don't get this wrong, but HOW you configure your PageSpeed module is totally UP TO YOU. ;)
Just like other additional modules, your settings should be tested on a long-term basis, as it depends very much on your very own, domain - specific content, which settings/modification you use. There is no general recommendation, but these three:
Code:
pagespeed on;
and the location setting for your cache - location:
Code:
pagespeed FileCachePath /YOUR-LOCATION/TO/THE/FOLDER/ngx_pagespeed_cache;
and last:
Code:
pagespeed EnableFilters combine_css,combine_javascript;
All these modifications have to be setup at your "/etc/nginx/nginx.conf", inside the "http" - section.​


Which (sub)domain - specific settings you add for your virtual host is then totally up to you and you are as well able to disable PageSpeed here again for the (sub)domain, or "DisableFilters" ( previously setup in your serverwide nginx - configuration ! ) for a virtual host. :)


For further informations, pls. read

 
Hi @UFHH01,
thanks for this incredible support. Put nothing to additional nginx settings in domains apache/nginx. But I forgot to set nginx as owner
Code:
chown nginx:nginx /var/ngx_pagespeed_cache;
I wondered why /var/ngx_pagespeed_cache was empty all the time.
As I solved the owner problem, immediately two directories were automatically created inside (v3 and shm_metadata_cache) and the file "!clean!time!".
I think pagespeed is running now.
Greets

Lot of greets :) 64 basic bytes ready
 
Last edited:
Code:
http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;

    # 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

    # 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

    pagespeed on;

    # Needs to exist and be writable by nginx.  Use tmpfs for best performance.
    pagespeed FileCachePath /var/ngx_pagespeed_cache;

}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

The rest of code in vhost template under additional nginx directives? I haven't done this step, I wanted to wait what do you recommend?
Code:
# 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$" { }
Am I right or totally wrong?
Can you please help me these steps.
Perhaps also with the vary and cache control headers.
It seems to configure only a few, but important things.

For the tmpfs recommendation I found an interesting solution by @IgorG written his year. Usually I do not change my filesystem, except one thing by installing whole OS with Plesk I expand /var/ by 750 GB. This is necessary on 1and1 servers by default-images.
Perhaps I can do this tmpfs on RAM later, after a period of time, hope it is not strictly necessary.
All the other interesting things like statistics and pagespeed console are a nice present.
But I only want to run pagespeed in basic configuration and see how and if it works.

Thanks and lots of greets

Where have you seen brotli was shippred with nginx ? I have check again the changelog but I haven't seen anything about hat.

Currently I have just compile the module with nginx.
Before nginx build :
Code:
cd /usr/share/nginx/modules/
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli
git submodule update --init --recursive
And add the following line in the .configure command :
Code:
--add-module=/usr/share/nginx/modules/ngx_brotli

Then to be able to use brotli, you have to remove all gzip settings. If Gzip is enabled, brotli will not work.

Edit : you are right @UFHH01 , it was only for pre-compressed content. I will create another thread about other modules.
 
Last edited:
Then to be able to use brotli, you have to remove all gzip settings. If Gzip is enabled, brotli will not work.
Sorry, this is a wrong / false statement.

But ( again! :( ): Pls. use a new/different thread, if you would like to discuss off - topic things. This thread clearly desrcibes the "How to compile NGINX with additional modules", with modules listed at => #1 . Nothing more and nothing less.
 
Here is a NEW part ( implemented "OpenSSL 1.1.1-dev" support, so that TLSv1.3 ciphers can be used
I would have a question to this part. Since I installed 1.1.0f-2~ubuntu16.04.1+deb.sury.org+1 last night, I would like to use this version. How can I do this?
Related to my last question there is another little problem.
I already use nginx 1.13.2 with pagespeed and brotli, et cetera. Is it better to remove the in use nginx and install the new nginx 1.13.5 new, or is there a way to upgrade nginx ?
Thanks for this amazing tutorial, Uwe.
 
Hi Dukemaster,

or is there a way to upgrade nginx ?
there is no "upgrade"/"update", if you compiled your onw NGINX - version. :rolleyes:

I can't really follow your question here, as all steps together from my tutorial, don't take longer than asking questions at this thread, how you might be able to use another way, Dukemaster. This is really not the intention of this step-by-step guide, which works on all tested environments ( CentOS 6.x + 7.x / Debian 7 + 8 / Ubuntu 14.04 + 16.04 ).

It would be quite odd now, as I informed you with the NEW additions at this contribution thread, HOW you are able to compile your own NGINX version with "OpenSSL 1.1.1-dev" , to answer each separate, unique question for other ways. Please let's stick at this thread with the actual provided step-by-step guide and use your very own thread, in case that you desire other compiliation ways for your nginx version. Thank you! :)
 
Last edited by a moderator:
THANKS INCREDIBLE @UFHH01
it worked without any problems like the previous release in your previous tutorial before you updated it.
Works like a charm!
I wonder a little about the path of fileCache which is completly different from pagespeed site, but this shouldn't be discussed here in this amazing thread and is perhaps on everyones choice.

GREAT WORK - GREAT TUTORIAL ! ! !

Qualys SSL-Ergebnis www.cosirex.comTLS 1.3.jpg

Qualys SSL-Protokoll Details www.cosirex.com-TLS 1.3.jpg

Qualys SSL - HTTP Requests www.cosirex.com TLS 1.3.jpg

Lots of greets and thanks a lot :):):)
 
Last edited:
@UFHH01 Many thanks for updating the guide.

Quick note though - 'text/html' needs to be removed from brotli_types as it causes a warning to be displayed due to the mime type being enabled by default.

Edit: I also recommend adding X25519, P-521 and P-256 to ssl_ecdh_curve parameter ie.

Code:
ssl_ecdh_curve X25519:P-521:P-384:P-256;

Cheers
 
Last edited:
Back
Top