]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/varnish/files/default.vcl
10b51d9ff3209d5bd1e2c418f9ef72279f4c6b12
[dsa-puppet.git] / modules / varnish / files / default.vcl
1 ##
2 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
3 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
4 ##
5
6
7 director packages_debian_org {
8         {
9                 .backend = holter
10                 .weight = 10000;
11         }
12         {
13                 .backend = powell
14                 .weight = 1;
15         }
16 }
17
18 backend holter {
19         # holter.debian.org
20         .host = "194.177.211.202";
21         .port = "80";
22 }
23 backend powell {
24         # powell.debian.org
25         .host = "87.106.64.223";
26         .port = "80";
27 }
28
29 sub vcl_recv {
30
31         # Add a unique header containing the client address
32         remove req.http.X-Forwarded-For;
33         set    req.http.X-Forwarded-For = req.http.rlnclientipaddr;
34
35         set req.backend = packages_debian_org;
36
37         return(lookup);
38 }
39
40 sub vcl_fetch {
41         if (beresp.status != 200 && beresp.status != 403 && beresp.status != 404 && beresp.status != 301 && beresp.status != 302) {
42                 return(restart);
43         }
44
45         # if i cant connect to the backend, ill set the grace period to be 600 seconds to hold onto content
46         set beresp.ttl = 600s;
47         set beresp.grace = 600s;
48
49         if (beresp.status >= 500) {
50                 set beresp.ttl = 0s;
51         }
52
53         set beresp.http.X-Cacheable = "YES";
54         return(deliver);
55 }
56
57
58 sub vcl_deliver {
59
60         set resp.http.X-Served-By = server.hostname;
61         if (obj.hits > 0) {
62                 set resp.http.X-Cache = "HIT";
63                 set resp.http.X-Cache-Hits = obj.hits;
64         } else {
65                 set resp.http.X-Cache = "MISS";
66         }
67
68         return(deliver);
69 }