forked from nysenate/OpenLegislation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.vcl
executable file
·102 lines (91 loc) · 1.97 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
backend default {
.host = "127.0.0.1";
.port = "8080";
}
# Restrict purge requests to local requests only.
acl purge {
"127.0.0.1";
}
#
# Below is a commented-out copy of the default VCL logic. If you
# redefine any of these subroutines, the built-in logic will be
# appended to your code.
sub vcl_recv {
if (req.request == "PURGE") {
if(!client.ip ~ purge) {
error 405 "Not allowed.";
}
else {
if(req.url ~ "search") {
ban( "req.url ~ search" );
}
else if(req.url ~ "views") {
ban("req.url ~ bills");
ban("req.url ~ resolutions");
ban("req.url ~ calendars");
ban("req.url ~ meetings");
ban("req.url ~ actions");
ban("req.url ~ votes");
ban("req.url ~ transcripts");
ban("req.url ~ sponsor");
ban("req.url ~ committee");
}
else if(req.url ~ "doc:") {
set req.url = regsub(req.url, "/?doc:", "");
ban("req.url ~ req.url");
}
else {
ban_url(req.url);
}
set req.http.foobar = "Purged "+req.url;
error 200 req.http.foobar;
remove req.http.foobar;
}
}
else {
if(req.url ~ "^/legislation/?$") {
return (pass);
} else if(req.url ~ "^/legislation") {
return (lookup);
} else {
return (pass);
}
}
}
sub vcl_pass {
return (pass);
}
sub vcl_hash {
hash_data(req.url);
#set req.hash += req.url;
if (req.http.host) {
hash_data(req.http.host);
#set req.hash += req.http.host;
} else {
hash_data(server.ip);
#set req.hash += server.ip;
}
return (hash);
}
sub vcl_hit {
if (obj.ttl <= 0s) {
return (pass);
}
return (deliver);
}
sub vcl_miss {
return (fetch);
}
sub vcl_fetch {
set beresp.ttl = 24h;
return (deliver);
}
sub vcl_deliver {
return (deliver);
}