We already have a rule to let Varnish follow the 302 redirects from the
/archive endpoint to the farm (/file) endpoint. However, this rule does
not handle all backends correctly, as some use relative redirects.
We now add a second rule to follow the relative (internal) redirects,
restoring this behavior.

A nice side-effect is that the artifacts are now delivered with the
correct file-name (instead of the farm hash).

Signed-off-by: Felix Moessbauer <felix.moessba...@siemens.com>
---
Changes since v1:

- Don't replace existing rule as still in use for lw07
- Do not explicitly set the http.host

Best regards,
Felix Moessbauer
Siemens AG

 .../roles/templates/snapshot/snapshot.debian.org.vcl.erb   | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb 
b/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb
index e7446ce8c..e93ee0437 100644
--- a/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb
+++ b/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb
@@ -39,6 +39,13 @@ sub vcl_backend_response {
         set bereq.url = regsub(beresp.http.location,"[^/]*","");
         return (retry);
     }
+    if (bereq.http.host != "snapshot-dev.debian.org" &&
+        bereq.retries == 0 &&
+        beresp.status == 302 &&
+        beresp.http.location ~ "^/file/") {
+        set bereq.url = beresp.http.location;
+        return (retry);
+    }
     # don't cache things too long
     if (beresp.ttl > 1w) {
         set beresp.ttl = 10m;
-- 
2.39.5

Reply via email to