1 // Varnish configuration snippets.
5 # You can have multiple ones; see vcl_recv.
12 if (req.restarts == 0) {
13 if (req.http.x-forwarded-for) {
14 set req.http.X-Forwarded-For =
15 req.http.X-Forwarded-For + ", " + client.ip;
17 set req.http.X-Forwarded-For = client.ip;
20 if (req.http.host ~ "analysis\.sesse\.net$" && req.url ~ "^/analysis\.pl") {
21 set req.backend_hint = analysis;
22 # Ignored by the backend; just to identify it in vcl_backend_response.
23 set req.http.x-analysis-backend = "backend1";
26 # You can check on e.g. /analysis2\.pl here if you have multiple
27 # backends; just remember to set x-analysis-backend to something unique.
31 if (resp.http.x-analysis) {
32 set resp.http.Date = now;
33 unset resp.http.X-Varnish;
36 unset resp.http.X-Powered-By;
38 unset resp.http.x-analysis;
39 unset resp.http.x-analysis-backend;
43 hash_data(regsub(req.url, "unique=.*$", ""));
45 hash_data(req.http.host);
52 sub vcl_backend_response {
53 if (bereq.http.host ~ "analysis") {
55 if (beresp.http.content-type ~ "text" || beresp.http.content-type ~ "json") {
56 set beresp.do_gzip = true;
58 if (bereq.url ~ "^/hash/") {
60 set beresp.http.x-analysis = 1;
61 set beresp.http.x-analysis-backend = bereq.http.x-analysis-backend;
64 if (beresp.http.content-type ~ "json") {
65 set beresp.http.x-analysis = 1;
66 set beresp.http.x-analysis-backend = bereq.http.x-analysis-backend;
67 ban ( "obj.http.x-analysis == 1 && " +
68 "obj.http.x-analysis-backend == " + bereq.http.x-analysis-backend + " && " +
69 "obj.http.x-rglm != " + beresp.http.x-rglm );