caddy-dns / cloudflare

Caddy module: dns.providers.cloudflare
Apache License 2.0
436 stars 59 forks source link

unrecognized directive: dns #51

Closed houmie closed 1 year ago

houmie commented 1 year ago

Hello,

I'm getting this error:

Error: adapting config using caddyfile: /etc/caddy/Caddyfile:24: unrecognized directive: dns

Caddyfile:

{
    log {
        output file /var/log/caddy/caddy.log {
            roll_size 1gb
            roll_keep 5
            roll_keep_for 720h
        }
    }
    servers 127.0.0.1:5001 {
        listener_wrappers {
            proxy_protocol
        }
        protocols h2c h1
    }
}

:5001 {
    root * /srv/http/default
    file_server
    bind 127.0.0.1
}

tls {
       dns cloudflare {env.CLOUDFLARE_AUTH_TOKEN}
       resolvers 1.1.1.1
}

:80 {
    redir https://{host}{uri} permanent
}

How comes it doesn't recognise it?

Thank you

misaert commented 1 year ago

Hi @houmie,

Maybe with CLOUDFLARE_API_KEY instead of CLOUDFLARE_AUTH_TOKEN?

mholt commented 1 year ago

Your Caddyfile is malformed; tls is being treated as a domain name, and dns is being treated as a directive, but actually tls is probably intended to be a directive, and dns is its subdirective.

See: https://caddyserver.com/docs/caddyfile/concepts#structure

@misaert Thanks for chiming in! :)