Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Issue #97: Added a few more settings for Varnish VCL.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Jun 14, 2015
1 parent 2017889 commit 158916d
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions provisioning/templates/drupalvm.vcl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,36 @@ backend default {
.first_byte_timeout = 300s;
}

# Access control list for PURGE requests.
acl purge {
"127.0.0.1";
}

# Respond to incoming requests.
sub vcl_recv {
# Add an X-Forwarded-For header with the client IP address.
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) {
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
}
else {
set req.http.X-Forwarded-For = client.ip;
}
}

# Only allow PURGE requests from IP addresses in the 'purge' ACL.
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return (synth(405, "Not allowed."));
}

This comment has been minimized.

Copy link
@benjifisher

benjifisher Oct 23, 2017

Contributor

Why 405? If you really mean 405, shouldn't the message be "Method not allowed"?

return (hash);
}

# Only cache GET and HEAD requests (pass through POST requests).
if (req.method != "GET" && req.method != "HEAD") {
return (pass);
}

# Pass through any administrative or AJAX-related paths.
if (req.url ~ "^/status\.php$" ||
req.url ~ "^/update\.php$" ||
Expand Down Expand Up @@ -85,7 +113,6 @@ sub vcl_backend_response {
unset beresp.http.set-cookie;
}

# Allow items to remain in cache up to 2 hours past their cache expiration.
set beresp.grace = 2h;
# Allow items to remain in cache up to 6 hours past their cache expiration.
set beresp.grace = 6h;
}

0 comments on commit 158916d

Please sign in to comment.