Caddy does not run when I enter "dns cloudflare" in Caddyfile

1. The problem I’m having:

I migrated CaddyFile from the old computer to the new computer to replace the web server.
But caddy doesn’t run. I get a Cloudflare error.

I don’t have a lot of software skills, so please excuse me if I’m asking unconventional questions.

(This post uses machine translation, there may be some parts that do not convey it. Thank you.)

2. Error messages:

2023/10/06 15:13:06.595	INFO	using provided configuration	{"config_file": "/etc/caddy/Caddyfile", "config_adapter": ""}
Error: adapting config using caddyfile: parsing caddyfile tokens for 'tls': /etc/caddy/Caddyfile:4 - Error during parsing: getting module named 'dns.providers.cloudflare': module not registered: dns.providers.cloudflare, import chain: ['']

3. Caddy version:

Both the old and new servers are the same version.

4. How I installed and ran Caddy:

a. System environment:

Old server:
Linux Mint 20.3

New server:

b. Command:

/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

I confirmed the above error with this command.

d. My complete Caddy config:, {
    root * /srv/www
    tls {
    dns cloudflare API_Token
    file_server {
    php_fastcgi unix//run/php/php7.4-fpm.sock

API_Token is entered directly without using environment variables.
The domain name is the same for both the old and new servers.
Delete the “tls{~~}” part from Caddyfile, it will run without any problems.

5. :

The error message says “module not registered: dns.providers.cloudflare”, but this module was not included on the old server. (“caddy list-modules”)
I also installed this module on the new server, but the situation did not change. (Confirmed that it was installed by running “caddy list-modules”)

A friend helped me set up Caddy on the old server, so there may be other settings. (But that possibility is low.)
If there is a way to check it please let me know.

Please let me know if you need any other information.

You need to get a build of Caddy with the GitHub - caddy-dns/cloudflare: Caddy module: dns.providers.cloudflare plugin. It doesn’t come with vanilla Caddy. You can download it from Download Caddy or build from source with xcaddy.

How did you install Caddy? If you used the apt repo, then follow these instructions to swap out the stock binary with a custom one.

Thank you, I did this and it works correctly now.

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