-
Notifications
You must be signed in to change notification settings - Fork 3
/
varnish-docker.vcl
62 lines (48 loc) · 1.12 KB
/
varnish-docker.vcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
vcl 4.1;
import std;
import directors;
backend chaos1 {
.host = "chaosbackend:8180";
}
backend chaos2 {
.host = "chaosbackend:8180";
}
sub vcl_init {
new chaos = directors.round_robin();
chaos.add_backend(chaos1);
chaos.add_backend(chaos2);
}
sub vcl_recv {
unset req.http.cookie;
if (req.url ~ "^/foo") {
set req.backend_hint = chaos1;
} else if(req.url ~ "^/bar") {
set req.backend_hint = chaos2;
} else {
set req.backend_hint = chaos.backend();
}
set req.http.Director = req.backend_hint;
}
sub vcl_hit {
set req.http.V-Cache = "HIT";
}
sub vcl_miss {
set req.http.V-Cache = "MISS";
}
sub vcl_pass {
set req.http.V-Cache = "PASS";
}
sub vcl_pipe {
set req.http.V-Cache = "PIPE";
}
sub vcl_backend_response {
set beresp.http.V-Backend = beresp.backend;
}
sub vcl_deliver {
set resp.http.V-Cache = req.http.V-Cache + ":" + obj.hits;
set resp.http.V-Director = req.http.Director;
std.log("prom=backends backend=" + resp.http.V-Backend + ",director="+ resp.http.V-Director + ",cache=" + req.http.V-Cache + ",status=" + resp.status);
}
sub vcl_synth {
set resp.http.Cache = "ERROR";
}