As long as CloudFlare sends the standard X-Forwarded-Proto
header, you can fix this by simply enabling RespectXForwardedProto
:
pagespeed RespectXForwardedProto on;
If that doesn't work, that probably means that CloudFlare is not sending proper X-Forwarded-Proto
headers. If so, you can try enabling PreserveUrlRelativity
:
pagespeed PreserveUrlRelativity on;
Which will rewrite URLs, but leave them as relative URLs (so that they work with both HTTP and HTTPS).