-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefault.vcl
executable file
·62 lines (50 loc) · 1.19 KB
/
default.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
61
62
vcl 4.1;
backend default {
# your application
.host = "127.0.0.1";
.port = "80";
}
acl localnetwork {
"10.0.0.0"/8;
"localhost";
}
sub vcl_recv {
if (req.method == "PURGE") {
if (client.ip ~ localnetwork) {
ban("req.http.host == " + req.http.host + " && req.url ~ " + req.url);
return(synth(200, "Purge OK : " + req.http.host + req.url));
}
return(synth(403, "Purge NG : " + req.http.host + req.url));
}
if (req.method != "GET" && req.method != "HEAD") {
return (pipe);
}
if (req.http.Authenticate || req.http.Authorization) {
return (pipe);
}
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") {
/* Non-RFC2616 or CONNECT which is weird. */
return (pipe);
}
return(hash);
}
sub vcl_hash {}
sub vcl_backend_response {}
sub vcl_deliver {
unset resp.http.X-Varnish;
unset resp.http.Via;
unset resp.http.Etag;
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
unset resp.http.x-url;
}