This repository has been archived on 2020-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
frontend-docker/build/Varnish/varnish.vcl

62 lines
1.2 KiB
Plaintext

vcl 4.0;
backend default {
.host = "haproxy";
.port = "80";
.max_connections = 300;
.first_byte_timeout = 240s;
.connect_timeout = 10s;
.between_bytes_timeout = 2s;
.proxy_header = 2;
}
sub vcl_recv {
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.http.Upgrade ~ "(?i)websocket") {
return (pipe);
}
if (req.method == "GET" || req.method == "HEAD") {
return (hash);
}
return (pass);
}
sub vcl_hash {
hash_data(req.url);
if (req.http.cookie) {
hash_data(req.http.cookie);
}
return (lookup);
}
sub vcl_hit {
if (obj.ttl + obj.grace > 0s) {
return (deliver);
}
return (pass);
}
sub vcl_miss {
return (fetch);
}
sub vcl_pipe {
if (req.http.upgrade) {
set bereq.http.upgrade = req.http.upgrade;
}
return (pipe);
}
sub vcl_backend_response {
if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {
return (abandon);
}
if (beresp.http.Cache-Control ~ "public") {
return (deliver);
}
return (pass);
}