[varnish] Add Varnish configuration and Dockerfile
This commit is contained in:
parent
db1ae9930c
commit
850d8d79a7
2 changed files with 60 additions and 0 deletions
11
varnish/Dockerfile
Normal file
11
varnish/Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
FROM centos:7
|
||||||
|
MAINTAINER Vincent Ambo <hej@tazj.in>
|
||||||
|
|
||||||
|
EXPOSE 6081 6082
|
||||||
|
|
||||||
|
RUN yum install -y epel-release && yum install -y varnish
|
||||||
|
|
||||||
|
ADD default.vcl /etc/varnish/default.vcl
|
||||||
|
|
||||||
|
CMD ulimit -n 131072 && \
|
||||||
|
/usr/sbin/varnishd -F -f /etc/varnish/default.vcl -a :6081 -T :6082 -t 120
|
49
varnish/default.vcl
Normal file
49
varnish/default.vcl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue