-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
custom.backend.vcl-sample
71 lines (65 loc) · 2.06 KB
/
custom.backend.vcl-sample
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
61
62
63
64
65
66
67
68
69
70
# First backend definition, with a built-in probe
backend default {
# I have Virtual Hosts that only listen to the Public IP
# so no 127.0.0.1 for me
# Backend is running on port 81
.host = "127.0.0.1";
.port = "80";
.probe = {
.url = "/ping";
.timeout = 1s;
.interval = 10s;
.window = 5;
.threshold = 2;
}
.first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?
.connect_timeout = 5s; # How long to wait for a backend connection?
.between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?
}
# Backend definition with entirely custom backend probes (raw HTTP headers) in a separated definition
backend custom_healthchecks {
.host = "127.0.0.1";
.port = "80";
.probe = custom_backend_probe; # Refer to the probe definition below, so we can reuse the probe.
.first_byte_timeout = 300s;
.connect_timeout = 5s;
.between_bytes_timeout = 2s;
}
probe custom_backend_probe {
.request = "GET /some/url HTTP/1.1"
"Host: some.virtualhost.domain.Tld"
"Connection: close"
"Accept-Encoding: text/html"
"User-Agent: Varnish Health Probe";
.interval = 10s;
.timeout = 10s;
.window = 2;
.threshold = 2;
}
# Below is an example redirector based on the Client IP (same returning class C subnet IP will get
# rerouted to the same backend, as long as it's available).
#
# In order for these to work, you need to define 2 backends as shown above named 'web1' and 'web2' (replace 'default'
# from the example above).
director pool_clientip client {
{
.backend = web1;
.weight = 1;
}
{
.backend = web2;
.weight = 1;
}
}
# Below is an example that will round-robin (based on the weight) to each backend.
# Web2 will get twice the hits as web1 since it has double the weight (= preference).
director pool_clientip {
{
.backend = web1
.weight = 1;
}
{
.backend = web2
.weight = 2;
}
}