Merge remote-tracking branch 'origin/master' into staging
[mirror/dsa-puppet.git] / modules / roles / templates / snapshot / snapshot.debian.org.vcl.erb
diff --git a/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb b/modules/roles/templates/snapshot/snapshot.debian.org.vcl.erb
new file mode 100644 (file)
index 0000000..25e6d12
--- /dev/null
@@ -0,0 +1,27 @@
+#-e This is a basic VCL configuration file for varnish.  See the vcl(7)
+#man page for details on VCL syntax and semantics.
+vcl 4.0;
+
+backend default {
+ .host = "127.0.0.1";
+ .port = "80";
+}
+
+# weasel's rule:
+sub vcl_recv {
+ if (req.http.Cache-Control ~ "(?i)no-cache") {
+   # Ignore requests via proxy caches and badly behaved crawlers
+   if (! (req.http.Via || req.http.User-Agent ~ "(?i)bot" || req.http.X-Purge)) {
+      return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops
+   }
+ }
+}
+
+sub vcl_purge {
+  # Only handle actual PURGE HTTP methods, everything else is discarded
+  if (req.method != "PURGE") {
+    # restart request
+    set req.http.X-Purge = "Yes";
+    return(restart);
+  }
+}