Caddy v2 with Cloudflare
1.7K
https://registry.hub.docker.com/r/reverie89/caddy
Based on official image, then added: caddy-dns/cloudflare module
Use the -security tag if you need additionally greenpau/security module
FROM caddy:2.7-builder AS builder
RUN xcaddy build \
--with github.com/caddy-dns/cloudflare
FROM caddy:2.7
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
docker-compose.yaml
services:
caddy:
image: fvillart/caddy-cloudflare
container_name: caddy
restart: always
environment:
- CLOUDFLARE_API_TOKEN=xxx
ports:
- "80:80/tcp"
- "443:443/tcp"
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- ./Caddyfile:/etc/caddy/Caddyfile
- ./config:/config
- ./data:/data
- /var/www:/var/www
Caddyfile:
subdomain.example.com {
tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}
reverse_proxy /* endpoint:80
}
example.com {
tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}
root * /var/www/example.com
}
Caddy v2 requires Cloudflare API token, not key. You will need to generate a token from your Cloudflare account if you don't have one.
Remember to mount /config and /data
Graceful Caddyfile reload: docker exec -w /etc/caddy {container_name} caddy reload
Format and overwrite Caddyfile: docker exec -w /etc/caddy {container_name} caddy fmt --overwrite
Content type
Image
Digest
sha256:4adafc87a…
Size
31 MB
Last updated
over 2 years ago
docker pull fvillart/caddy-cloudflare