https redirection loop even with X-Forwarded-Proto
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.