diff options
author | Vincent Ambo <tazjin@gmail.com> | 2015-11-19T21·23+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2015-11-19T21·30+0100 |
commit | 850d8d79a7829ca6f4feed0b4e89f1e1e328d4a0 (patch) | |
tree | d98e86ebd4046ff47524331e4efb872d51710a5c /varnish/default.vcl | |
parent | db1ae9930cec8cdf892967c9d7b9c63bf81550ec (diff) |
[varnish] Add Varnish configuration and Dockerfile
Diffstat (limited to 'varnish/default.vcl')
-rw-r--r-- | varnish/default.vcl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/varnish/default.vcl b/varnish/default.vcl new file mode 100644 index 000000000000..5710a589cc3f --- /dev/null +++ b/varnish/default.vcl @@ -0,0 +1,49 @@ +vcl 4.0; + +# By default, Varnish will run on the same servers as the blog. Inside of +# Kubernetes this will be inside the same pod. + +backend default { + .host = "localhost"; + .port = "8000"; +} + +# Purge requests should be accepted from localhost +acl purge { + "localhost"; +} + +sub vcl_recv { + # Allow HTTP PURGE from ACL above + if (req.method == "PURGE" && client.ip ~ purge) { + return (purge); + } + + # Redirect /en to / (no more multi-language support) + if (req.url ~ "^/en") { + set req.url = regsub(req.url, "^/en/", "/"); + return (synth(301, "")); + } + + # Don't cache admin page + if (req.url ~ "^/admin") { + return (pass); + } +} + +sub vcl_backend_response { + # Cache everything for at least 1 minute. + if (beresp.ttl < 1m) { + set beresp.ttl = 1m; + } + + # Add an HSTS header to our response +} + +sub vcl_synth { + # Execute redirects + if (resp.status == 301) { + set resp.http.Location = req.url; + return (deliver); + } +} |