Nginx – How to configure HTTPS Nginx + Pagespeed + Varnish + Apache


I currently have the following set-up:

Nginx (https) => ssl offloaded => Varnish (http) => Apache (http)

I want to add mod_pagespeed or nginx pagespeed in the mix. Any ideas where to add it? Should I look into adding pagespeed to Apache or to Nginx?

The following page has some information, but I'm unsure what to do with our specific set-up.

I was thinking of exploring one of the following options:

Add pagespeed to nginx, making pagespeed use the cached pages from varnish / apache and executing on the fly
Add pagespeed to Apache, and configuring it in such a way that the pages get cached based on user agent / screen resolution.
If I understand correctly, the artice I point out above refers to the second option. It might be easier to set up the first option though I think?

Thanks in advance for the help!

Best Answer

I would probably add PageSpeed to Apache. That way the pages are optimised once, cached in Varnish, and served out by Nginx. This will be more efficient, reducing CPU use, if you put PageSpeed on Nginx it may have to do it on every request.

Note: this is based on the documentation I've read, not practical experience.