#-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); } } # We rate-limit requests by clients. # Currently, we do that at the netfilter level, so one # request per connection works best. sub vcl_deliver { if (remote.ip != "127.0.0.1" && remote.ip != "::1") { 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); } }