Building Caddy using xcaddy - cloudfare issues

1. Caddy version (caddy version):

2.2.1

2. How I run Caddy:

Running caddy via docker-compose in a debian VM (proxmox host environment)

a. System environment:

latest debian
docker version 19.03.13

b. Command:

docker-compose up -d

c. Service/unit/compose file:

full Dockerfile

FROM caddy:2.2.1-builder AS builder

RUN xcaddy build v2.2.1 --with github.com/caddy-dns/cloudflare@latest

FROM caddy:2.2.1

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

full docker-compose.yml

version: "3.7"
services:
  caddy:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"

    environment:
      - "CADDYPATH=/web/certs"
      - CLOUDFARE_EMAIL=MY_EMAIL
      - CLOUDFARE_API_TOKEN=MY_TOKEN

    volumes:
      - /web/Caddyfile:/etc/caddy/Caddyfile
      - $HOME/.caddy:/web/certs
      - /web/site:/srv
      - /var/docks/caddy:/data
      - /var/docks/caddy:/config

d. My complete Caddyfile or JSON config:

http://plex.greatwhitelab.net {
        redir https://plex.greatwhitelab.net
}

https://plex.greatwhitelab.net {
        tls MY_EMAIL {
                dns cloudfare {env.CLOUDFLARE_API_TOKEN}
                }
        reverse_proxy 192.168.42.12:32400
        encode gzip
}

3. The problem I’m having:

I think even though im building with xcaddy and specifying the cloudfare plugin that its somehow not loading? I have had so many issues at this point, I really want to love caddy but something about my specific situation is making things very difficult.

4. Error messages and/or full log output:

run: adapting config using caddyfile: parsing caddyfile tokens for ‘tls’: /etc/caddy/Caddyfile:17 - Error during parsing: getting DNS provider module named ‘cloudfare’: module not registered: dns.providers.cloudfare

5. What I already tried:

i have already made sure that I am using an API token (not KEY) and that I have Zone.DNS.edit permissions and Zone.Zone.read permissions for the token being used.

i have also verified that all my volumes are correctly being mounted to the docker container by using “docker inspect caddy”

i have no idea what the issue is at this point

6. Links to relevant resources:

FYI, it’s not safe to use the same path for both volumes:

      - /var/docks/caddy:/data
      - /var/docks/caddy:/config

You should change this to something like:

      - /var/docks/caddy/data:/data
      - /var/docks/caddy/config:/config

As for your error, it’s just a simple typo:

run: adapting config using caddyfile: parsing caddyfile tokens for ‘tls’: /etc/caddy/Caddyfile:17 - Error during parsing: getting DNS provider module named ‘cloudfare’: module not registered: dns.providers.cloudfare

cloudfarecloudflare :sweat_smile:

You made the same typo multiple times, including your environment variables, so make sure to clean that up everywhere!

3 Likes

wow. this is super embarrassing. I have been messing with this for HOURS.

regardless, thanks for the suggestion and keen eye. the likelihood of me noticing that after staring at the screen this long is zero. i will leave this post up to bask in my shame.

2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.