Wildcard Domain with duckdns

1. The problem I’m having:

I try to use duckdns with wildcard domains. Lets say i have mydom.duckdns.org and i want to reach out to my wiki server via https://wiki.mydom.duckdns.org and another server via https://ipcheck.mydom.duckdns.org
I am very confused about all this possible settings and after days/weeks i thought i might ask if someone can help me with this.
I found also caddy-dns/duckdns but not very clear if this would help (see links)

2. Error messages and/or full log output:

<!--
Please DO NOT REDACT any information except credentials. Leave domain names intact!
Please DO NOT POST TRUNCATED LOG LINES as systemd is notorious for this.
Please USE THIS COMMAND TO VIEW LOGS with systemd:
    $ journalctl -u caddy --no-pager | less +G`
Please DO NOT USE WEB BROWSERS. Use `curl -vL` instead.
Please ENABLE DEBUG MODE FIRST by adding "debug" to the global options of your Caddyfile. See https://caddyserver.com/docs/caddyfile/options#debug for an example.
-->
INF ts=1747193646.346666 logger=http msg=using ACME account account_id=https://acme-staging-v02.api.letsencrypt.org/acme/acct/199755364 account_contact=[]
ERR ts=1747193646.9855785 logger=tls.obtain msg=could not get certificate from issuer identifier=*.mydom.duckdns.org issuer=acme-v02.api.letsencrypt.org-directory error=[*.mydom.duckdns.org] solving challenges: *.mydom.duckdns.org: no solvers available for remaining challenges (configured=[http-01 tls-alpn-01] offered=[dns-01] remaining=[dns-01]) (order=https://acme-staging-v02.api.letsencrypt.org/acme/order/199755364/24613652004) (ca=https://acme-staging-v02.api.letsencrypt.org/directory)
ERR ts=1747193646.9856243 logger=tls.obtain msg=will retry error=[*.mydom.duckdns.org] Obtain: [*.mydom.duckdns.org] solving challenges: *.mydom.duckdns.org: no solvers available for remaining challenges (configured=[http-01 tls-alpn-01] offered=[dns-01] remaining=[dns-01]) (order=https://acme-staging-v02.api.letsencrypt.org/acme/order/199755364/24613652004) (ca=https://acme-staging-v02.api.letsencrypt.org/directory) attempt=3 retrying_in=120 elapsed=182.790409169 max_duration=2592000
[details="Summary"]
This text will be hidden
[/details]

3. Caddy version:

v2.10.0

4. How I installed and ran Caddy:

a. System environment:

rasperry pi 5
Debian GNU/Linux 12 (bookworm)
using docker compose v2.35.1
docker community in version 28.1.1

b. Command:

first install docker and created my network

curl -fsSL https://get.Docker.com -o get-Docker.sh
sudo sh get-Docker.sh
sudo usermod -aG docker $USER
docker network create -d bridge proxy

c. Service/unit/compose file:

My docker-compose.yml

services:
  caddy:
    image: caddy:2
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    volumes:
      - /home/pi/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
      - /home/pi/caddy/caddy-config:/config
      - /home/pi/caddy/caddy-data:/data
    environment:
      - DOMAIN=mydon.duckdns.org
      - EMAIL=mail.address@gmail.com
      - DUCKDNS_TOKEN="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      - LOG_FILE=/data/access.log
    networks:
      - myNt

networks:
  myNt:
    name: proxy
    external: true

d. My complete Caddy config:

*.mydom.duckdns.org:443 {
  log {
    level INFO
    output file {$LOG_FILE} {
      roll_size 10MB
      roll_keep 10
    }
  }
@wiki host wiki.mydom.duckdns.org
  handle @wiki {
  respond "Wiki"
  }
@ipcheck host ipcheck.mydom.duckdns.org
  handle @ipcheck {
  respond "IPCHECK"
  }
}

5. Links to relevant resources:

When reading the documentation it seems that i need a Module for duckdns
dns.providers.duckdns
but it is very unclear for me on how to implement this in a docker container.
https://caddyserver.com/docs/extending-caddy
unclear if i need to build something with xcaddy or when i download it from https://caddyserver.com/download
the how to get it into the container?

You can find pre-built Caddy + DuckDNS Docker images on DockerHub or GitHub, or you can build your own. Here’s an example of a Dockerfile you can use:

FROM caddy:latest AS builder

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

FROM caddy:latest

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

You can also search this forum - plenty of folks run Caddy with DuckDNS, and there are lots of examples you can draw from.

1 Like

Hello,
so i learned that i need to install/copy go and i need also xcaddy. Once installed and try to build my image i get an error:

pi@docker5:~/caddy $ docker build --tag 250520-caddy:1.0.0 .
[+] Building 6.6s (5/6)                                                                                                                                                                                                       docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                    0.0s
 => => transferring dockerfile: 273B                                                                                                                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/caddy:latest                                                                                                                                                                         1.0s
 => [internal] load .dockerignore                                                                                                                                                                                                       0.0s
 => => transferring context: 2B                                                                                                                                                                                                         0.0s
 => CACHED [builder 1/2] FROM docker.io/library/caddy:latest@sha256:30ccf0cb027e1d06cd6e453c04fc1c8eec665629b22ed69602c14c8a0512ead0                                                                                                    0.0s
 => ERROR [builder 2/2] RUN xcaddy build  --with github.com/caddy-dns/duckdns                                                                                                                                                           5.3s
------
 > [builder 2/2] RUN xcaddy build  --with github.com/caddy-dns/duckdns:
0.250 /bin/sh: xcaddy: not found
------
Dockerfile:6
--------------------
   5 |
   6 | >>> RUN xcaddy build \
   7 | >>>  --with github.com/caddy-dns/duckdns
   8 |
--------------------
ERROR: failed to solve: process "/bin/sh -c xcaddy build  --with github.com/caddy-dns/duckdns" did not complete successfully: exit code: 127

but when running the version command it works:

pi@docker5:~/caddy $ xcaddy version
v0.4.4 h1:xstmMhsxrDF/1rnncpi+CLbBfxEP0PjjdtXe3YFwnuo=

For me it sounds like a path issue.

For go i had defined in the .profile

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Is there anything i need to define also for xcaddy?

Change this:

To this:

FROM caddy:builder AS builder

Yeah, sorry, I made a typo. I was typing the Dockerfile off the top of my head. Just go with what @Mohammed90 said

Hello,
thanks for your help. Build is now working. Maybe this help someone else. First installing go. For this get the file with wget in your current directory

wget https://go.dev/dl/go1.24.3.linux-arm64.tar.gz

Then untar the file

sudo tar -C /usr/local -xzf go1.24.3.linux-arm64.tar.gz

Now edit the .profile file in the home directory

nano ~/.profile
add at the end of the file:

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

After this you can run go version command

 $ go version
go version go1.24.3 linux/arm64

After this xcaddy is needed. I am not 100% but i believe i did the following:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-xcaddy-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-xcaddy.list
sudo apt update
sudo apt install xcaddy

With this i was ready to create my own caddy image. Dockerfile i had created

# First try to build my own caddy image
FROM caddy:builder AS builder

# MAINTAINER User <user@mailserver.net>

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

FROM caddy:latest

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

Then build it with:

docker build --tag 250520-caddy:1.0.0 .

The name 250520-caddy:1.0.0 is the name:version i gave to it.

Then you need to modify the docker compose to use this and change your Caddyfile.
It works for me. Many thanks

You don’t need any of this because the build is happening inside the Docker builder container, which has all of these

1 Like