caddy-dynamicdns icon indicating copy to clipboard operation
caddy-dynamicdns copied to clipboard

Allow updating subdomains without changing the base domain using dynamic_domains

Open iwismer opened this issue 1 month ago • 2 comments

Let say I own example.com and want to update some subdomains for it. I'd use the following config:

{
	dynamic_dns {
		provider cloudflare {env.CLOUDFLARE_API_TOKEN}
		domains {
			# This is required to actually update subdomains
			example.com
		}
		dynamic_domains
	}
}

foo.example.com {
	redir http://google.com
}
bar.example.com {
	redir http://google.com
}

Then, looking in my cloudflare dashboard, I'd see the following A records:

  • example.com -> 1.1.1.1
  • foo.example.com -> 1.1.1.1
  • bar.example.com -> 1.1.1.1

But, I don't want to dynamically update the base example.com record, but it doesn't seem like there's a way to set this up.

I'd like there to be a way to update using dynamic_domains a way to update the subdomains (foo.example.com) only, without updating the A/AAAA record for the base domain (example.com).

Hopefully this example makes sense, and I'm not just missing some obvious configuration in the docs.

A specific example of where this is useful is when I have a single domain with content hosted from multiple servers. With the current implementation, they will fight over the base domain A/AAAA record and constantly be switching it back and forth.

iwismer avatar Nov 22 '25 20:11 iwismer

In the domains block, the first argument of each line is the zone name, followed by individual subdomains. Since you don't list any subdomains, IIRC it assumes the whole zone.

mholt avatar Nov 25 '25 16:11 mholt

So does this mean I need to setup DNS zones in order to prevent the main domain from having its DNS updated?

iwismer avatar Nov 25 '25 16:11 iwismer

A DNS zone is an authority boundary -- typically a registered domain name. So if your domain is example.com, you need to do something like example.com foo bar near the top of your Caddyfile to update subdomains.

mholt avatar Dec 04 '25 22:12 mholt

What I'm asking for here is to be able to update the records for subdomains without updating the record for the root domain.

iwismer avatar Dec 09 '25 12:12 iwismer

Right, that's what example.com foo bar does. example.com @ would update records for the "root" domain.

mholt avatar Dec 10 '25 17:12 mholt