https redirection loop even with X-Forwarded-Proto https redirection loop even with X-Forwarded-Proto apache apache

https redirection loop even with X-Forwarded-Proto


As noted above:

We had to:

  • Put RewriteLocation 0 in the ListenHTTPs
  • Fix a domain name issue in the config
ListenHTTPS  ReWriteLocation 0


In my case, Varnish was configured to normalize URLs and removed scheme and domain:

set req.url = regsub(req.url, "^http[s]?://[^/]+", "");

So that the redirect response for http://example.com to https://example.com would be cached and the request to https://example.com would return this cached response.

Removing this normalization or adding

hash_data(req.http.Https);

to sub vcl_hash helped.