From b1422e1053164b8b6109d8dbb295af0ac865c2ab Mon Sep 17 00:00:00 2001 From: Christian Wiedemann Date: Tue, 12 Mar 2019 00:07:15 +0100 Subject: [PATCH] Cache HTTP/HTTPS separate. Right now varnish caches either HTTP or HTTPS pages. This can lead to unexpected behavior, especially with Apache .htaccess HTTP to HTTPS redirect rules. (Redirect loops). Think it makes to hash them based on X-Forwarded-Proto. --- conf/default.vcl.tmpl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/conf/default.vcl.tmpl b/conf/default.vcl.tmpl index 868c2b0..5df3745 100644 --- a/conf/default.vcl.tmpl +++ b/conf/default.vcl.tmpl @@ -172,3 +172,10 @@ sub vcl_synth { "} ); return (deliver); } + +# Cache HTTP and HTTPS separate. +sub vcl_hash { + if (req.http.X-Forwarded-Proto) { + hash_data(req.http.X-Forwarded-Proto); + } +}