Switching to Cloudflare DNS triggers this error "Unsupported X-Forwarded-Proto: https, https for URL" with mod_pagespeed 1.11.33.5-0 @26313

Viewed 284

I have multiple domains on the same server, all setup with Cloudflare DNS and no problems, but for one domain I get this error whenever I try switching DNS to Cloudflare :

[Sat Dec 05 11:41:22.471013 2020] [pagespeed:warn] [pid 26313:tid 140310743021312] [mod_pagespeed 1.11.33.5-0 @26313] [1205/114122:WARNING:instaweb_context.cc(402)] Unsupported X-Forwarded-Proto: https, https for URL http://mydomain/page.php? protocol not changed .

  • I thought it was maybe CF forced HTTPS rewrite, but it does the same when I disable it.
  • I looked also in the .htaccess but found nothing related to HTTPS rewrite. I even deleted the .htaccess to test but it did not stop the warnings.
  • I tried changing all the settings on CF but nothing made a difference.
  • I really think its an issue on my server side, but its weird that none of the other domains suffer the same issue.
  • I don't have much control on the apache config of my host
1 Answers
Unsupported X-Forwarded-Proto: https, https

This would imply you have a proxy (or "load balancer") in addition to Cloudflare. Both will set an X-Forwarded-Proto header and one or other is merging them (arguably incorrectly, according to the "HTTP standard" at least, although X-Forwarded-Proto is only a defacto standard so there are no official rules governing how multiple headers should be merged, so https, https isn't necessarily wrong.)

mod_pagespeed appears to be hardcoded to issue this warning if this header (when set) is not exactly http or https:

  if (!STR_CASE_EQ_LITERAL(*x_forwarded_proto_header, "http") &&
      !STR_CASE_EQ_LITERAL(*x_forwarded_proto_header, "https")) {
    LOG(WARNING) << "Unsupported X-Forwarded-Proto: " << x_forwarded_proto
                 << " for URL " << url << " protocol not changed.";
    return false;
  }

Try setting the following in your .htaccess (or server config) to change this to simply https:

RequestHeader edit X-Forwarded-Proto "^https,\s?https$" "https" early

If this doesn't work, try removing the early argument.

Related