Debian 8 - Jessie Varnish 4.1.3 varnishncsa logging to stdout varnish-modules 0.9.1 by Varnish Software Extends globalgiving/varnish
To use this container, you will need to provide your custom config.vcl (which is usually the case).
docker run -d \
--link web-app:backend-host \
--volumes-from web-app \
--env 'VCL_CONFIG=/data/path/to/varnish.vcl' \
--log-driver=syslog --log-opt syslog-address=tcp://192.168.0.42:123 \
globalgiving/varnish
In the above example we assume that:
- You have your application running inside
web-appcontainer and web server there is running on port 80 (although you don't need to expose that port, as we use --link and varnish will connect directly to it) web-appcontainer has/datavolume withvarnish.vclsomewhere thereweb-appis aliased inside varnish container asbackend-host192.168.0.42is running a daemon on port123which can consume syslog data.- Your
varnish.vclshould contain at least backend definition like this:
backend default {
.host = "backend-host";
.port = "80";
}
You can configure Varnish daemon by following env variables:
VCL_CONFIG
/etc/varnish/default.vcl
CACHE_SIZE64m
VARNISHD_PARAMS-p default_ttl=3600 -p default_grace=3600
The output of varnishncsa is piped to the standard out of the container, allowing the docker daemon to read it and direct that data to anywhere you wish.
The format (variable definitions) passed to varnishncsa:
[%{x-forwarded-for}i] %u %t "%r" %s %b %T "%{Referer}i" "%{User-agent}i" %{Varnish:handling}x