Initial commit
This commit is contained in:
commit
3e9080e219
9
tasks/main.yml
Normal file
9
tasks/main.yml
Normal file
@ -0,0 +1,9 @@
|
||||
- name: Copy Varnish configuration
|
||||
template:
|
||||
follow: yes
|
||||
src: 'varnish.vcl.j2'
|
||||
dest: /etc/varnish/default.vcl
|
||||
notify: Run service actions
|
||||
tags:
|
||||
- varnish
|
||||
- configs
|
63
templates/varnish.vcl.j2
Normal file
63
templates/varnish.vcl.j2
Normal file
@ -0,0 +1,63 @@
|
||||
vcl 4.1;
|
||||
|
||||
backend default {
|
||||
.path = "{{ varnish.backend.sock }}";
|
||||
.max_connections = 300;
|
||||
.first_byte_timeout = 240s;
|
||||
.connect_timeout = 10s;
|
||||
.between_bytes_timeout = 2s;
|
||||
}
|
||||
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.http.Range) {
|
||||
return (pass);
|
||||
}
|
||||
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) {
|
||||
hash_data(req.http.cookie);
|
||||
}
|
||||
return (lookup);
|
||||
}
|
||||
sub vcl_hit {
|
||||
return (deliver);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (beresp.status == 301) {
|
||||
return(deliver);
|
||||
}
|
||||
return (pass);
|
||||
}
|
Reference in New Issue
Block a user