0
votes

Apache 2.2.15 on RHELS 6.1

Using mod_pagespeed on a server behind https (implemented by the network's Reverse Proxy).

All html urls are written as "//server.example.com/path/to/file.css" (so, without the protocol specified).

Problem : using the default configuration, pagespeed rewrites the urls as "http://server.example.com/path/to/file.css"

I'm trying to figure out how to have it rewrite the urls as https (or leave it unspecified as //).

After reading the documentation, I tried using ModPagespeedMapOriginDomain like this

ModPagespeedMapOriginDomain http://localhost https://server.example.com

Also tried

ModPagespeedMapOriginDomain http://localhost //server.example.com
ModPagespeedMapOriginDomain localhost server.example.com

... To no avail. Urls keep being rewritten with "http://".

Question: how can I have pagespeed use https instead of http in its urls?

Full pagespeed config here, if needed

2

2 Answers

0
votes

It turns out mod_pagespeed does not work with "protocol-relative" urls.

Still, the issue is bypassed if you enable trim_urls

ModPagespeedEnableFilters trim_urls

Be mindful of the potential risks (depending on your javascript codebase, ajax calls could break or produce unexpected html).

0
votes

Adding this to your configuration might work:

ModPagespeedRespectXForwardedProto on

That works, if your reverse proxy forwards the X-Forwarded-Proto header in its requests. That request header tells PageSpeed what the original protocol was that was used for the request at the loadbalancer, and thereby hands it all it needs to know to correctly rewrite urls.