Unfortunately after Snowden Revelations, Google is not reliable about data privacy and data security. Google Approached to Move PageSpeed to Apache Incubator. However, Many Modules Do Use Google’s CDNs to serve the assets (which demands thorough knowledge to tweak to change). As still, CDN locations are not made to null URL by default, it will have precaution for the sites and site-owners who want highest privacy of the users. Here is Guide Install Google/Apache PageSpeed With HTTPS, HTTP/2 With Apache2 on Ubuntu 18.04. At present, Google/Apache PageSpeed works out of the box with HTTPS. Previously, we published guide on how to install Apache2 on Ubuntu 18.04 and configure for HSTS, HTTPS, HTTP/2 etc. Although, this guide is for Ubuntu 18.04, it does work on Ubuntu 16.04.
mod_http2
provides an HTTP2 variable which can be used to provide a different configuration for HTTP2 sessions to disable some filters in such sessions. Of course whether using PageSpeed with bleeding edge modules is practical that need testing on own production site. The module erratically does break basic padlock test. Also, if you are using a reverse proxy (like we have guide to use Nginx to add IPv6 with reverse proxy) in front that needs extra settings (we discussed in this guide). However, yet it may not respect directive and demands your random manual checking.
How To Install Google/Apache PageSpeed With HTTPS, HTTP/2 With Apache2
After installation, you’ll have a file named /etc/default/mod-pagespeed
, with the below content :
---
1 2 | repo_add_once="false" repo_reenable_on_distupgrade="true" |
If you do not want to use the Google repository, before installing the .deb package
run:
1 | touch /etc/default/mod-pagespeed |
If you do not understand what it means, you can skip the above step and proceed:
1 2 3 4 | apt update -y apt upgrade -y sudo reboot # SSH back |
You can download the latest, stable version of mod_pagespeed
module for Apache from the official site :
1 | https://www.modpagespeed.com/doc/download |
At time of writing, that is :
1 | wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb |
Install with the below commands :
1 2 3 4 | sudo dpkg -i mod-pagespeed-*.deb sudo apt-get -f install ls -al rm mod-pagespeed-stable_current_amd64.deb |
mod_pagespeed_ap24.so
got activated, with pagespeed.conf
, pagespeed_libraries.conf
config files. Also a standalone JavaScript minifier pagespeed_js_minify
got installed. To uninstall on need, you need to run simple :
1 2 | Remove # before running it seriously # sudo apt-get remove mod-pagespeed-stable |
Now, go to /etc/apache2/sites-available/ and run an ls -al :
1 2 | cd /etc/apache2/sites-available/ ls -al |
There will be your virtual host config file for HTTPSS site. Within virtual host scope, add :
1 2 | ModPagespeedFetchHttps enable ModPagespeedRespectXForwardedProto on |
Run configtest :
1 | apachectl -t |
More settings, including for HTTP/2, shown on official documentation :
1 | https://www.modpagespeed.com/doc/https_support |
And restart Apache :
1 | sudo systemctl restart apache2 |
If you curl your website to fetch header, you’ll see Pagespeed header :
1 2 3 | curl -I https://thecustomizewindows.com/ | grep X-Mod-Pagespeed X-Mod-Pagespeed: 1.13.35.2-0 |
Open the configuration file :
1 | nano /etc/apache2/mods-available/pagespeed.conf |
At present, default settings enough good to test how good or bad it is. You need many changes for pagespeed_admin
, one is (change your-ip-address
to your current IP of internet connection) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <Location /pagespeed_admin> Order allow,deny Allow from localhost Allow from 127.0.0.1 Allow from your-ip-address SetHandler pagespeed_admin </Location> <Location /pagespeed_global_admin> Order allow,deny Allow from localhost Allow from 127.0.0.1 Allow from your-ip-address SetHandler pagespeed_global_admin </Location> |
Save and restart Apache :
1 2 | apachectl -t sudo systemctl restart apache2 |
You should see web admin http://your-ip-address/pagespeed_admin
. You should read documentation :
1 | https://www.modpagespeed.com/doc/ |
I informed you to manually check webpages randomly to find whether PageSpeed is breaking your SSL padlock.
Tagged With setup apache pagespeed https , apache pagespeed ubuntu 18 04 , mod pagespeed on ubuntu 18 04 , Módulo Pagespeed and http2 , ubuntu 18 04 minify