Sign inSign up

pgilad/caddy-cloudflare

By pgilad

•Updated 2 days ago

Caddy alpine with cloudflare-dns add-on

Image
Networking
Security
1

587

pgilad/caddy-cloudflare repository overview

⁠Caddy with Cloudflare DNS

Caddy with the Cloudflare DNS module included. Use Cloudflare DNS-01 challenges to get and renew HTTPS certificates, including wildcard certificates, without building a custom image.

Based on the official Caddy Alpine image, with caddy-dns/cloudflare⁠ added through xcaddy.

Maintained by Gilad Peleg⁠.

⁠Image

docker pull pgilad/caddy-cloudflare:2.11.9-alpine

Supported platforms: linux/amd64 and linux/arm64.

Tags use <caddy-version>-alpine. Published tags cannot be overwritten. Use an explicit version tag in your configuration.

See all available tags⁠.

⁠Quick start

Use a domain with DNS hosted by Cloudflare. Replace example.com below with your domain, and point its A/AAAA records to your server.

⁠1. Create a Cloudflare API token

Create a token with these permissions for the DNS zone that Caddy will manage:

  • Zone → Zone → Read
  • Zone → DNS → Edit

Save it in a .env file next to compose.yaml:

CLOUDFLARE_API_TOKEN=replace-with-your-token

Keep this file out of version control.

⁠2. Create conf/Caddyfile
example.com {
    tls {
        dns cloudflare {env.CLOUDFLARE_API_TOKEN}
    }

    respond "Caddy with Cloudflare DNS is running."
}

Replace respond with your site configuration or a reverse_proxy directive.

⁠3. Create compose.yaml
services:
  caddy:
    image: pgilad/caddy-cloudflare:2.11.9-alpine
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    environment:
      CLOUDFLARE_API_TOKEN: ${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN in .env}
    volumes:
      - ./conf:/etc/caddy:ro
      - caddy_data:/data
      - caddy_config:/config

volumes:
  caddy_data:
  caddy_config:
⁠4. Start Caddy
docker compose up -d

Keep the /data volume across container updates. It stores certificates, private keys, and other required data.

⁠Documentation and support

⁠License

This repository uses the MIT license⁠. Included software retains its own licenses.

Tag summary

Content type

Image

Digest

sha256:776d9005d…

Size

41 MB

Last updated

2 days ago

docker pull pgilad/caddy-cloudflare:2.11.9-alpine