"Module not registered" error but it exists in list-modules

1. The problem I’m having:

I’m trying to build caddy with the cloudfare module so that I can do a tls challenge to generate certificates. I am getting an error saying that the module is not registered however when running list-modules the module is there. I have looked for errors in the caddyfile but can’t seem to figure out what is causing the issue.

2. Error messages and/or full log output:

Error: adapting config using caddyfile: parsing caddyfile tokens for 'tls': Caddyfile:48 - Error during parsing: getting module named 'dns.providers.cloudfare': module not registered: dns.providers.cloudfare

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

a. Docker Image:

Caddy installed through docker container with custom built image;

FROM caddy:builder AS builder

RUN xcaddy build \
    --with github.com/caddy-dns/cloudflare

FROM caddy:latest

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

b. Caddyfile:

Caddyfile is as below

{$DOMAIN1}:443 {
        log {
                level INFO
                output file {$LOG_FILE} {
                        roll_size 10MB
                        roll_keep 10
                }
        }
        tls {
          dns cloudfare {$CLOUDFARE}
        }
        reverse_proxy 10.0.0.50:802 {
                header_up X-REAL-IP {remote_host}
        }
}

{$DOMAIN2} {
        log {
                level DEBUG
                output file {$LOG_FILE} {
                        roll_size 10MB
                        roll_keep 10
                }
        }
        tls {
          dns cloudfare {$CLOUDFARE}
        }
        reverse_proxy 10.0.0.50:8123 {
                header_up X-REAL-IP {remote_host}
        }
}

5. Extra information

Caddy list-modules shows that the module is listed as a non-standard module.

caddy list-modules
admin.api.load
admin.api.metrics
admin.api.pki
admin.api.reverse_proxy
caddy.adapters.caddyfile
caddy.config_loaders.http
caddy.listeners.http_redirect
caddy.listeners.tls
caddy.logging.encoders.console
caddy.logging.encoders.filter
caddy.logging.encoders.filter.cookie
caddy.logging.encoders.filter.delete
caddy.logging.encoders.filter.hash
caddy.logging.encoders.filter.ip_mask
caddy.logging.encoders.filter.query
caddy.logging.encoders.filter.regexp
caddy.logging.encoders.filter.rename
caddy.logging.encoders.filter.replace
caddy.logging.encoders.json
caddy.logging.writers.discard
caddy.logging.writers.file
caddy.logging.writers.net
caddy.logging.writers.stderr
caddy.logging.writers.stdout
caddy.storage.file_system
events
http
http.authentication.hashes.bcrypt
http.authentication.hashes.scrypt
http.authentication.providers.http_basic
http.encoders.gzip
http.encoders.zstd
http.handlers.acme_server
http.handlers.authentication
http.handlers.copy_response
http.handlers.copy_response_headers
http.handlers.encode
http.handlers.error
http.handlers.file_server
http.handlers.headers
http.handlers.map
http.handlers.metrics
http.handlers.push
http.handlers.request_body
http.handlers.reverse_proxy
http.handlers.rewrite
http.handlers.static_response
http.handlers.subroute
http.handlers.templates
http.handlers.tracing
http.handlers.vars
http.ip_sources.static
http.matchers.expression
http.matchers.file
http.matchers.header
http.matchers.header_regexp
http.matchers.host
http.matchers.method
http.matchers.not
http.matchers.path
http.matchers.path_regexp
http.matchers.protocol
http.matchers.query
http.matchers.remote_ip
http.matchers.vars
http.matchers.vars_regexp
http.precompressed.br
http.precompressed.gzip
http.precompressed.zstd
http.reverse_proxy.selection_policies.cookie
http.reverse_proxy.selection_policies.first
http.reverse_proxy.selection_policies.header
http.reverse_proxy.selection_policies.ip_hash
http.reverse_proxy.selection_policies.least_conn
http.reverse_proxy.selection_policies.random
http.reverse_proxy.selection_policies.random_choose
http.reverse_proxy.selection_policies.round_robin
http.reverse_proxy.selection_policies.uri_hash
http.reverse_proxy.transport.fastcgi
http.reverse_proxy.transport.http
http.reverse_proxy.upstreams.a
http.reverse_proxy.upstreams.multi
http.reverse_proxy.upstreams.srv
pki
tls
tls.certificates.automate
tls.certificates.load_files
tls.certificates.load_folders
tls.certificates.load_pem
tls.certificates.load_storage
tls.client_auth.leaf
tls.get_certificate.http
tls.get_certificate.tailscale
tls.handshake_match.remote_ip
tls.handshake_match.sni
tls.issuance.acme
tls.issuance.internal
tls.issuance.zerossl
tls.stek.distributed
tls.stek.standard

  Standard modules: 100

dns.providers.cloudflare

  Non-standard modules: 1

  Unknown modules: 0

How are you building the container? How are you running it? How are you running list-modules to check it?

I am building the container in portainer and running from there. I’ve extracted a docker-compose file below which has the details in it.

I am running list-modules by attaching to the docker container and running caddy list-modules

version: "3.6"
services:
  Caddy_cloudfare_dns:
    cap_drop:
      - "AUDIT_CONTROL"
      - "BLOCK_SUSPEND"
      - "DAC_READ_SEARCH"
      - "IPC_LOCK"
      - "IPC_OWNER"
      - "LEASE"
      - "LINUX_IMMUTABLE"
      - "MAC_ADMIN"
      - "MAC_OVERRIDE"
      - "NET_ADMIN"
      - "NET_BROADCAST"
      - "SYSLOG"
      - "SYS_ADMIN"
      - "SYS_BOOT"
      - "SYS_MODULE"
      - "SYS_NICE"
      - "SYS_PACCT"
      - "SYS_PTRACE"
      - "SYS_RAWIO"
      - "SYS_RESOURCE"
      - "SYS_TIME"
      - "SYS_TTY_CONFIG"
      - "WAKE_ALARM"
    command:
      - "caddy"
      - "run"
      - "--config"
      - "/etc/caddy/Caddyfile"
      - "--adapter"
      - "caddyfile"
    container_name: "Caddy_cloudfare_dns"
    environment:
      - "CADDY_VERSION=v2.4.3"
      - "CLOUDFARE=[REDACTED]"
      - "DOMAIN1=vw.thompsonfam.com.au"
      - "DOMAIN2=hassio.thompsonfam.com.au"
      - "LOG_FILE=/data/access.log"
      - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      - "XDG_CONFIG_HOME=/config"
      - "XDG_DATA_HOME=/data"
    hostname: "209479f094ca"
    image: "caddy_cloudfare_dns:latest"
    logging:
      driver: "json-file"
      options: {}
    networks:
      - "caddy"
    ports:
      - "4431:443/tcp"
      - "801:80/tcp"
    restart: "always"
    volumes:
      - "/home/pi/caddy/data:/data"
      - "/home/pi/caddy/caddyfile:/etc/caddy/Caddyfile"
      - "/home/pi/caddy/config:/config"
    working_dir: "/srv"
networks:
  caddy:
    external: true
    name: "caddy"

That’s a very old version of Caddy. Please use the latest version, v2.6.4.

Why are you overriding PATH? That’s strange.

You don’t need these, the Caddy image already sets those.

I recommend using unless_stopped instead, it’s a safer policy.

I’ve deleted those environment variables and I’m still having the issue.

Is there another way to load the module?

So I just tried a new caddyfile which kind of worked.

‘’’

{$DOMAIN1}:443 {
log {
level INFO
output file {$LOG_FILE} {
roll_size 10MB
roll_keep 10
}
}
tls {
dns cloudfare {$CLOUDFARE}
}
reverse_proxy 10.0.0.50:802 {
header_up X-REAL-IP {remote_host}
}
}

{$DOMAIN2} {
log {
level DEBUG
output file {$LOG_FILE} {
roll_size 10MB
roll_keep 10
}
}
tls internal
reverse_proxy 10.0.0.50:8123 {
header_up X-REAL-IP {remote_host}
}
}

‘’’
I noticed the error was for domain 2 so I’ve tried using tls internal instead. For whatever reason domain 1 is now working

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