caddy-dns / acmeproxy

MIT License
1 stars 0 forks source link

Error - caddyfile: parsing caddyfile tokens for 'acme_dns': wrong argument count or unexpected line ending after #1

Closed christianbur closed 8 months ago

christianbur commented 8 months ago

I am currently using acme.sh with the acmeproxy plugin and the dns-alias-mode. Now I am testing if caddy fulfills my requirements, for this I need wildcard certificates. I hope to realize this with the acmeproxy plugin and "dns_challenge_override_domain" option.

However, when testing I always get the error "caddyfile: parsing caddyfile tokens for 'acme_dns': wrong argument count or unexpected line ending after". Since I don't know caddy very well and this plugin is only 5 days old, I don't know where to look for the problem.

my Dockerfile:

FROM caddy:builder-alpine AS builder

RUN caddy-builder \
    github.com/caddy-dns/acmeproxy

FROM caddy:alpine

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

my demo Caddyfile

{

  debug
  acme_ca https://acme-staging-v02.api.letsencrypt.org/directory

  email webmaster@domain.de
  acme_dns acmeproxy https://dnsapi.domain.de/acme {
    username cb_acme
    password aasdfsdfaaffffffffg634
  }
}

*.domain.de {
  tls {
    dns_challenge_override_domain anwx.de.ddns.anwx.de
    resolvers 1.1.1.1
  }

  reverse_proxy nginx-mailcow:8080 {
    health_uri /
    lb_try_duration 5s
  }
}

error:

# dc down && dc up -d && dc logs -f
[+] Running 1/0
 ✔ Container caddy-caddy-1  Removed                                                                                                       0.0s 
[+] Running 1/1
 ✔ Container caddy-caddy-1  Started                                                                                                       0.0s 
caddy-caddy-1 exited with code 0
caddy-caddy-1  | {"level":"info","ts":1703418067.531503,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
caddy-caddy-1  | Error: adapting config using caddyfile: parsing caddyfile tokens for 'acme_dns': wrong argument count or unexpected line ending after 'cb_acme', at /etc/caddy/Caddyfile:9
caddy-caddy-1  | {"level":"info","ts":1703418068.4975526,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
caddy-caddy-1  | Error: adapting config using caddyfile: parsing caddyfile tokens for 'acme_dns': wrong argument count or unexpected line ending after 'cb_acme', at /etc/caddy/Caddyfile:9

I also get the error within the domain section with "dns acmeproxy https://...".

If I define the "endpoint" twice, I get the error message "API token already set" from the acmeproxy plugin, so the plugin does the evaluation.

{

  debug
  acme_ca https://acme-staging-v02.api.letsencrypt.org/directory

  email webmaster@domain.de
  acme_dns acmeproxy https://dnsapi.domain.de {
    endpoint https://dnsapi.domain.de
    username cb_acme
    password aasdfsdfaaffffffffg634
  }
}
...

error:


# dc down && dc up -d && dc logs -f
[+] Running 1/0
 ✔ Container caddy-caddy-1  Removed                                                                                                                                                                     0.0s 
[+] Running 1/1
 ✔ Container caddy-caddy-1  Started                                                                                                                                                                     0.0s 
caddy-caddy-1 exited with code 0
caddy-caddy-1  | {"level":"info","ts":1703418328.224295,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
caddy-caddy-1  | Error: adapting config using caddyfile: parsing caddyfile tokens for 'acme_dns': API token already set, at /etc/caddy/Caddyfile:9
caddy-caddy-1  | {"level":"info","ts":1703418329.223979,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
caddy-caddy-1  | Error: adapting config using caddyfile: parsing caddyfile tokens for 'acme_dns': API token already set, at /etc/caddy/Caddyfile:9

@KalleDK How do I define "username" and "password" correctly?

KalleDK commented 8 months ago

Start with the readme file where there are examples. I've not tried alias mode, but It should be independent of this module. Try without alias and then add it when you know it works.

christianbur commented 8 months ago

Thank you for the quick response. At the moment I am still in the process of implementing the example, but that's exactly what's not working for me. When I copy the "tls" block into my caddyfile, I get exactly the error described.

Error: adapting config using caddyfile: parsing caddyfile tokens for 'tls': wrong argument count or unexpected line ending after 'user', at /etc/caddy/Caddyfile:26

KalleDK commented 8 months ago

Try the newest version, this works for me. Though this is not either alias or wildcard, but that should also be provider independent afaik.

{
  acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}

my.domain.com {
  tls {
    dns acmeproxy https://ns03.example.com:9090 {
      username flaf
      password secretpass
    }
  }

  reverse_proxy nginx-mailcow:8080 {
    health_uri /
    lb_try_duration 5s
  }
}
christianbur commented 8 months ago

Thank you.

I am one step further, now the acme challange cannot be passed to the backend via POST. The problem is that this plugin uses "FQDN"instead of "fqdn" and "Value" instead of "value"` as parameters, therefore, the values are not accepted during the transfer. Of course I could changed my backend, but it should be changed in the plugin. The reason for this is that, for example, acme.sh and Lego also pass lower-case parameters, so compatibility is given.

Example of working plugins: Lego/traefik acme.sh

KalleDK commented 8 months ago

There are no official RFC for the spec, but I can see that mdbraber/acmeproxy uses lowercase, so I've changed it in the provider to lowercase :)

christianbur commented 8 months ago

I have received a certificate, but only with the propagation_timeout and propagation_delay parameters. For the DNS resolution, somehow the public IP address of the server itself is tried (of course this does not work), so the test fails.

my config:

  tls {
    issuer acme {
      # https://caddyserver.com/docs/caddyfile/directives/tls#acme
      dir https://acme-staging-v02.api.letsencrypt.org/directory
      email webmaster@yyyy.de
      dns acmeproxy https://dnsapi.yyyyyyyyyyyy.de/acme {
        username cb_acme
        password yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
      }
      propagation_timeout -1
      propagation_delay 30s
      resolvers 9.9.9.9
    }

}

KalleDK commented 8 months ago

I don't think I can help with that, as that has nothing to do with the provider. This only creates and removes dns entries.

christianbur commented 8 months ago

I have found the error, it has to do with the fact that I operate DNS servers myself. I think everything will be up and running soon, thanks for the help.

KalleDK commented 8 months ago

No problem - please close the issue if everything is fine :)