Skip to content

Commit

Permalink
Update drupal8 varnish VCL based on latest release of drupal vm.
Browse files Browse the repository at this point in the history
  • Loading branch information
kierenevans committed Nov 21, 2016
1 parent 3ea05df commit 9bb5062
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions drupal8-varnish/4.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ docker push

As for all images based on the ubuntu base image, see
[the base image README](../../ubuntu/16.04/README.md)

We configure the varnish config file, `/etc/varnish/default.vcl` to be one from
[geerlingguy's Drupal VM](https://raw.githubusercontent.com/geerlingguy/drupal-vm/3.5.2/provisioning/templates/drupalvm.vcl.j2)
16 changes: 8 additions & 8 deletions drupal8-varnish/4.0/etc/confd/templates/varnish/default.vcl.tmpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
vcl 4.0;

# This Varnish VCL has been adapted from the Four Kitchens VCL for Varnish 3.
# Based on https://github.com/geerlingguy/drupal-vm/blob/2bc896658adc94a92de9ac917bca780341b98642/provisioning/templates/drupalvm.vcl.j2

import std;
# Based on https://raw.githubusercontent.com/geerlingguy/drupal-vm/3.5.2/provisioning/templates/drupalvm.vcl.j2

# Default backend definition. Points to Apache, normally.
backend default {
.host = "{{ getenv "VARNISH_BACKEND_HOST" }}";
.port = "{{ getenv "VARNISH_BACKEND_PORT" }}";
.first_byte_timeout = 300s;
}

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

Expand Down Expand Up @@ -39,7 +39,7 @@ sub vcl_recv {
if (!client.ip ~ purge) {
return (synth(405, "Not allowed."));
}
return (hash);
return (purge);
}

# Only allow BAN requests from IP addresses in the 'purge' ACL.
Expand All @@ -49,13 +49,13 @@ sub vcl_recv {
return (synth(403, "Not allowed."));
}

# Logic for the ban, using the Purge-Cache-Tags header. For more info
# Logic for the ban, using the Cache-Tags header. For more info
# see https://github.com/geerlingguy/drupal-vm/issues/397.
if (req.http.Purge-Cache-Tags) {
ban("obj.http.Purge-Cache-Tags ~ " + req.http.Purge-Cache-Tags);
if (req.http.Cache-Tags) {
ban("obj.http.Cache-Tags ~ " + req.http.Cache-Tags);
}
else {
return (synth(403, "Purge-Cache-Tags header missing."));
return (synth(403, "Cache-Tags header missing."));
}

# Throw a synthetic page so the request won't go to the backend.
Expand Down

0 comments on commit 9bb5062

Please sign in to comment.