Permalink
Browse files

Merge pull request #723 from amazeeio/dynamic-varnish

Dynamic varnish director
  • Loading branch information...
Schnitzel committed Nov 13, 2018
2 parents 56c78b8 + 709f65c commit bf603f9291c9e5424cde0a414760059790033038
Showing with 23 additions and 9 deletions.
  1. +11 −9 images/varnish-drupal/drupal.vcl
  2. +12 −0 images/varnish/Dockerfile
@@ -1,14 +1,7 @@
vcl 4.0;
import std;
# set backend default
backend default {
.host = "${VARNISH_BACKEND_HOST:-nginx}";
.port = "${VARNISH_BACKEND_PORT:-8080}";
.first_byte_timeout = 35m;
.between_bytes_timeout = 10m;
}
import dynamic;
# Allow purging from localhost
# @TODO allow from openshift network
@@ -19,14 +12,23 @@ acl purge {
"192.168.0.0"/16;
}
sub vcl_init {
new www_dir = dynamic.director(
port = "${VARNISH_BACKEND_PORT:-8080}",
first_byte_timeout = 90s,
between_bytes_timeout = 90s,
ttl = 60s);
}
# This configuration is optimized for Drupal hosting:
# Respond to incoming requests.
sub vcl_recv {
if (req.url ~ "^/varnish_status$") {
return (synth(200,"OK"));
}
# set the backend, which should be used:
set req.backend_hint = default;
set req.backend_hint = www_dir.backend("${VARNISH_BACKEND_HOST:-nginx}");
# Always set the forward ip.
if (req.restarts == 0) {
@@ -1,7 +1,19 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons
FROM alpine:3.7 as vmod
ENV VERSION=5.2
RUN apk --no-cache add varnish varnish-dev automake autoconf libtool python py-docutils make
RUN cd /tmp && wget https://github.com/nigoroll/libvmod-dynamic/archive/${VERSION}.zip && \
unzip ${VERSION}.zip && cd libvmod-dynamic-${VERSION} && \
./autogen.sh && ./configure && make && make install
FROM alpine:3.7
COPY --from=vmod /usr/lib/varnish/vmods/libvmod_dynamic.* /usr/lib/varnish/vmods/
LABEL maintainer="amazee.io"
ENV LAGOON=varnish

0 comments on commit bf603f9

Please sign in to comment.