1. The problem I’m having:
Hi,
I would have questions about Caddy DNS modules and Caddy Docker Proxy, and I don’t succeed to get answers on their dedicated help channels, that is why I am asking here.
I am trying to find explanations about what exactly Caddy DNS modules do and don’t, and how to configure them properly with Caddy Docker Proxy.
I am using Cloudflare as my DNS zone.
Both my public IPV4 and IPV6 can change, so I want both to be updated automatically by Caddy.
Additionnally, I would like caddy to automatically create CNAME records when I add a new subdomain configuration. I couldn’t find the information if caddy DNS modules can do that or not.
If I understood correctly, Caddy DNS modules (GitHub - caddy-dns/cloudflare: Caddy module: dns.providers.cloudflare) do not update A / AAAA DNS records. To do that, another module is required, for example GitHub - mholt/caddy-dynamicdns: Caddy app that keeps your DNS records (A/AAAA) pointed at itself. .
I am trying to get that configured through Caddy Docker Proxy, if possible as global configuration so that it applies to every subdomain I have.
So far, my configuration is the following:
platform: ${PLATFORM}
container_name: caddy
ports:
- 80:80
- 443:443/tcp
- 443:443/udp
environment:
- CADDY_INGRESS_NETWORKS=services
- DOCKER_HOST=tcp://dockersocket:2375
- PUID=${PUID}
- PGID=${PGID}
- TZ=${TZ}
depends_on:
- dockersocket
- sablier
networks:
- services
- dockersocket
volumes:
# - /var/run/docker.sock:/var/run/docker.sock:ro
- ${CONFIG_FOLDER}/caddy:/data
restart: unless-stopped
labels:
caddy.dynamic_dns.provider: cloudflare ${CADDY_CLOUDFLARE_DNSTOKEN}
caddy.dynamic_dns.domains.: ${DOMAIN}
caddy.acme_dns: cloudflare ${CADDY_CLOUDFLARE_DNSTOKEN}
But it doesn’t produce the expected configuration, that is
{
dynamic_dns {
provider cloudflare {env.CLOUDFLARE_API_TOKEN}
domains {
example.com
}
}
}
What I get is
{
dynamic_dns {
provider cloudflare {env.CLOUDFLARE_API_TOKEN}
domains {
example {
com
}
}
}
}
I couldn’t find how to escape the . in my configuration.
I would have the following questions:
- Am I using the right modules to achieve CNAME automatic creation/deletion and A / AAAA automatic updating ?
- Is it possible to apply their configuration globally without having to copy it for every subdomain ?
- Am I configuring them the right way ?
- How to escape the . character in a Caddy Docker Proxy configuration ? Is there another way to achieve the result ?
Thanks for any answer, have a nice day.
2. Error messages and/or full log output:
3. Caddy version: v2.9.1
4. How I installed and ran Caddy:
Built with Docker and xcaddy, with GitHub - caddy-dns/cloudflare: Caddy module: dns.providers.cloudflare and GitHub - mholt/caddy-dynamicdns: Caddy app that keeps your DNS records (A/AAAA) pointed at itself. plugins
a. System environment:
Docker on Debian
b. Command:
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
c. Service/unit/compose file:
platform: ${PLATFORM}
container_name: caddy
ports:
- 80:80
- 443:443/tcp
- 443:443/udp
environment:
- CADDY_INGRESS_NETWORKS=services
- DOCKER_HOST=tcp://dockersocket:2375
- PUID=${PUID}
- PGID=${PGID}
- TZ=${TZ}
depends_on:
- dockersocket
- sablier
networks:
- services
- dockersocket
volumes:
# - /var/run/docker.sock:/var/run/docker.sock:ro
- ${CONFIG_FOLDER}/caddy:/data
restart: unless-stopped
labels:
caddy.dynamic_dns.provider: cloudflare ${CADDY_CLOUDFLARE_DNSTOKEN}
caddy.dynamic_dns.domains.: ${DOMAIN}
caddy.acme_dns: cloudflare ${CADDY_CLOUDFLARE_DNSTOKEN}
For each of my services:
labels:
caddy: gitea.${DOMAIN}
caddy.reverse_proxy: gitea:3000
d. My complete Caddy config:
{
acme_dns cloudflare REDACTED
grace_period 10s
dynamic_dns {
provider cloudflare REDACTED
domains {
mydomain {
com
}
}
}
}
auth.mydomain.com {
reverse_proxy authentik-server:9000
}
gitea.mydomain.com {
reverse_proxy gitea:3000
}
openmediavault.mydomain.com {
reverse_proxy http://192.168.1.27:10997
}
vault.mydomain.com {
reverse_proxy vaultwarden:80
}