Sign inSign up

travix/varnish

By travix

•Updated almost 10 years ago

Docker implementation of Varnish

Image
1

587

travix/varnish repository overview

⁠Varnish

Docker implementation of Varnish⁠

⁠Environment variables

NameDescriptionDefault value
BACKEND_GRACEVCL Grace⁠2h
CACHE_MAX_AGECache max age10
CACHE_SIZECache size64M
CACHE_TTLCache TTL10s
OFFLOAD_TO_HOSTHost of backend applicationlocalhost
OFFLOAD_TO_PORTPort of backend application5000
VARNISH_HEALTH_CHECK_PATHVarnish health check path/healthz
VARNISH_PORTVarnish port to use80
VARNISH_PARAMSCommand line configuration⁠

⁠Custom Varnish configuration

You can customize the VCL configuration and mount it as follow:

docker run -t -i \
  -p 80:80 \
  -v "$(pwd)/default.vcl:/etc/varnish/default.vcl" \
    varnish

⁠Testing

# Run NGINX as backend
docker run -d --name=nginx-alpine nginx:alpine

# Run Varnish
docker run -t -i -p 8080:80 \
  -e "OFFLOAD_TO_HOST=nginx-alpine" \
  -e "OFFLOAD_TO_PORT=80" \
  --link=nginx-alpine \
  varnish

# Curl
curl http://localhost:8080 -I

# Response:
# >> HTTP/1.1 404 Not Found
# >> Date: Mon, 21 Nov 2016 13:45:35 GMT
# >> Content-Type: text/html
# >> Content-Length: 169
# >> Age: 0
# >> X-Cache: MISS
# >> X-Cache-Hits: 0
# >> Connection: keep-alive

⁠License

MIT © Travix International⁠

Tag summary

Content type

Image

Digest

Size

33.2 MB

Last updated

almost 10 years ago

docker pull travix/varnish