From: Peter Palfrader Date: Sat, 6 Apr 2019 12:50:26 +0000 (+0200) Subject: snapshot: follow redirects to /file/ in varnish X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=8935526beed75fae866203e722e63a06a8ff9233;p=mirror%2Fdsa-puppet.git snapshot: follow redirects to /file/ in varnish --- diff --git a/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb b/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb index 8659b637f..c01fcb73e 100644 --- a/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb +++ b/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb @@ -35,3 +35,14 @@ sub vcl_deliver { set resp.http.connection = "close"; } } + +sub vcl_backend_response { + if (bereq.retries == 0 && + beresp.status == 302 && + beresp.http.location ~ "https?://[^/]*/file/") { + set beresp.http.location = regsub(beresp.http.location,"^https?://",""); + set bereq.http.host = regsub(beresp.http.location,"/.*$",""); + set bereq.url = regsub(beresp.http.location,"[^/]*",""); + return (retry); + } +}