diff --git a/docker/Dockerfile b/docker/Dockerfile index 50cf0e7..961f0d6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,12 +6,13 @@ LABEL maintainer="Mark Nottingham " RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - nodejs npm git openssh-client \ + nodejs npm git openssh-client telnet \ squid \ nginx \ trafficserver \ apache2 \ varnish \ + golang \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean @@ -61,6 +62,13 @@ EXPOSE 8004 EXPOSE 8005 +# caddy + +RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest +RUN ~/go/bin/xcaddy build --with github.com/caddyserver/cache-handler +COPY caddy/Caddyfile /etc/caddy/Caddyfile +EXPOSE 8006 + # setup COPY setup.sh /sbin/setup.sh diff --git a/docker/README.md b/docker/README.md index a1e386a..c2d78ab 100644 --- a/docker/README.md +++ b/docker/README.md @@ -14,4 +14,3 @@ To add a new reverse proxy: 4. In `serve.sh`, start the server in the background 5. In `/test-docker.sh`, add the `PROXY_PORT` to the case statement -To run on the CI server, modify `/.circleci/config.yml` suitably. diff --git a/docker/caddy/Caddyfile b/docker/caddy/Caddyfile new file mode 100644 index 0000000..5ecf0d6 --- /dev/null +++ b/docker/caddy/Caddyfile @@ -0,0 +1,28 @@ +# The Caddyfile is an easy way to configure your Caddy web server. +# +# Unless the file starts with a global options block, the first +# uncommented line is always the address of your site. +# +# To use your own domain name (with automatic HTTPS), first make +# sure your domain's A/AAAA DNS records are properly pointed to +# this machine's public IP, then replace ":80" below with your +# domain name. + +{ + order cache before rewrite + cache +} + +:8006 { + cache { + default_cache_control no-store + } + reverse_proxy http://127.0.0.1:8000 { + transport http { + dial_timeout 10s + } + } +} + +# Refer to the Caddy docs for more information: +# https://caddyserver.com/docs/caddyfile diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index dc3a1fb..afaf96c 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -20,6 +20,9 @@ if [[ ! -z $1 ]] ; then # varnish sed -i s/127.0.0.1/$1/ /etc/varnish/default.vcl + # caddy + sed -i s/127.0.0.1/$1/ /etc/caddy/Caddyfile + serve.sh fi diff --git a/docker/serve.sh b/docker/serve.sh index 634a8ae..c483098 100755 --- a/docker/serve.sh +++ b/docker/serve.sh @@ -15,3 +15,6 @@ source /etc/apache2/envvars echo "* Starting Varnish" /usr/sbin/varnishd -j unix -a 0.0.0.0:8005 -f /etc/varnish/default.vcl -p default_ttl=0 -p default_grace=0 -p default_keep=3600 -s malloc,64M + +echo "* Starting Caddy" +HOME=/root /caddy run --config /etc/caddy/Caddyfile diff --git a/test-docker.sh b/test-docker.sh index 7e53a83..dc57545 100755 --- a/test-docker.sh +++ b/test-docker.sh @@ -5,9 +5,9 @@ PIDFILE=/tmp/http-cache-test-server.pid -ALL_PROXIES=(squid nginx apache trafficserver varnish nuster) +ALL_PROXIES=(squid nginx apache trafficserver varnish caddy nuster) DOCKER_PORTS="" -for PORT in {8001..8005}; do +for PORT in {8001..8006}; do DOCKER_PORTS+="-p ${PORT}:${PORT} " done @@ -71,6 +71,9 @@ function test_proxy { varnish) PROXY_PORT=8005 ;; + caddy) + PROXY_PORT=8006 + ;; nuster) PROXY_PORT=9001 ;;