From 8935526beed75fae866203e722e63a06a8ff9233 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sat, 6 Apr 2019 14:50:26 +0200 Subject: [PATCH] snapshot: follow redirects to /file/ in varnish --- .../templates/snapshot/snapshot.debian.org.vcl.erb | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); + } +} -- 2.20.1