Skip to content

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS with the Cloudflare module built in.

License

Notifications You must be signed in to change notification settings

runbgp/caddy-cloudflare-dns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Latest Release caddy on DockerHub Docker Build

caddy-cloudflare-dns

Please see the official Caddy Docker Image for deployment instructions.

Builds are available at the following Docker repositories:

Getting started

  1. Add your CLOUDFLARE_EMAIL and CLOUDFLARE_API_TOKEN as environment variables to your docker-compose.yml or docker-run command.
docker-compose.yml
services:
  caddy:
    image: ghcr.io/runbgp/caddy-cloudflare-dns:latest
    restart: unless-stopped
    container_name: caddy
    ports:
      - "80:80"
      - "443:443"
    networks:
      - caddy
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./data:/data
      - ./config:/config
    environment:
      - CLOUDFLARE_EMAIL=$CLOUDFLARE_EMAIL
      - CLOUDFLARE_API_TOKEN=$CLOUDFLARE_API_TOKEN
      - ACME_AGREE=true

networks:
  caddy:
    name: caddy
docker run
docker run -it --name caddy \
   -p 80:80 \
   -p 443:443 \
   -v caddy_data:/data \
   -v caddy_config:/config \
   -v $PWD/Caddyfile:/etc/caddy/Caddyfile \
   -e CLOUDFLARE_EMAIL=$CLOUDFLARE_EMAIL \
   -e CLOUDFLARE_API_TOKEN=$CLOUDFLARE_API_TOKEN \
   -e ACME_AGREE=true \
   ghcr.io/runbgp/caddy-cloudflare-dns:latest

Cloudflare API

You can obtain your Cloudflare API token via the Cloudflare Portal. To create an API token with minimal scope, the following steps are needed:

  1. Log into the Cloudflare dashboard, navigate to account settings and create an API token.
  2. Grant the following permissions:
    • Zone / Zone / Read
    • Zone / DNS / Edit
  3. Add the following to your Caddyfile's tls directive.
tls {$CLOUDFLARE_EMAIL} { 
  dns cloudflare {$CLOUDFLARE_API_TOKEN}
}

Image tags

See available tags here.

To select a specific version of caddy, set your Docker image tag to the Caddy version you'd like to use, e.g. runbgp/caddy-cloudflare-dns:2.8.0