2020-10-31 15:34:48 +00:00
|
|
|
vcl 4.1;
|
|
|
|
import std;
|
|
|
|
|
|
|
|
backend default {
|
2020-11-01 14:28:32 +00:00
|
|
|
.host = "127.0.0.1";
|
|
|
|
.port = "7500";
|
2020-10-31 15:55:26 +00:00
|
|
|
.max_connections = 300;
|
|
|
|
.first_byte_timeout = 240s;
|
|
|
|
.connect_timeout = 10s;
|
|
|
|
.between_bytes_timeout = 2s;
|
2020-10-31 15:34:48 +00:00
|
|
|
}
|
|
|
|
sub vcl_recv {
|
|
|
|
unset req.http.user-agent;
|
|
|
|
if ( req.method != "GET" &&
|
|
|
|
req.method != "HEAD" &&
|
|
|
|
req.method != "PUT" &&
|
|
|
|
req.method != "POST" &&
|
|
|
|
req.method != "TRACE" &&
|
|
|
|
req.method != "OPTIONS" &&
|
|
|
|
req.method != "PATCH" &&
|
|
|
|
req.method != "DELETE") {
|
|
|
|
return (pipe);
|
|
|
|
}
|
|
|
|
if (req.method == "GET" || req.method == "HEAD") {
|
|
|
|
return (hash);
|
|
|
|
}
|
|
|
|
return (pass);
|
|
|
|
}
|
|
|
|
sub vcl_hash {
|
|
|
|
hash_data(req.url);
|
|
|
|
hash_data(req.http.host);
|
|
|
|
if (req.http.cookie ~ "pleroma_key|gitea_incredible|grafana_session") {
|
|
|
|
hash_data(req.http.cookie);
|
|
|
|
}
|
|
|
|
if (req.http.authorization) {
|
|
|
|
hash_data(req.http.authorization);
|
|
|
|
}
|
|
|
|
return (lookup);
|
|
|
|
}
|
|
|
|
sub vcl_backend_response {
|
|
|
|
set beresp.do_stream = false;
|
|
|
|
set beresp.do_gzip = true;
|
|
|
|
if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {
|
|
|
|
if (bereq.is_bgfetch){
|
|
|
|
return (abandon);
|
|
|
|
}
|
|
|
|
set beresp.uncacheable = true;
|
|
|
|
return (deliver);
|
|
|
|
}
|
|
|
|
if (beresp.http.Set-Cookie || beresp.http.Cache-Control ~ "no-cache|no-store|private") {
|
|
|
|
set beresp.uncacheable = true;
|
|
|
|
return (deliver);
|
|
|
|
}
|
|
|
|
if (beresp.http.ETag || beresp.http.Last-Modified || bereq.http.If-Modified-Since) {
|
|
|
|
set beresp.grace = 1h;
|
|
|
|
set beresp.keep = 12h;
|
|
|
|
}
|
|
|
|
if (beresp.status == 301) {
|
|
|
|
set beresp.ttl = 24h;
|
|
|
|
}
|
|
|
|
return (deliver);
|
|
|
|
}
|
|
|
|
sub vcl_deliver {
|
|
|
|
if (req.proto ~ "HTTP/2.0" && resp.http.keep-alive) {
|
|
|
|
unset resp.http.keep-alive;
|
|
|
|
}
|
|
|
|
if (obj.hits > 0) {
|
|
|
|
set resp.http.X-Cache = "HIT";
|
|
|
|
} else {
|
|
|
|
set resp.http.X-Cache = "MISS";
|
|
|
|
}
|
|
|
|
return (deliver);
|
|
|
|
}
|