Skip to content

caddy: Dynamic DNS generates incorrect zone for non-wildcard subdomain domain entries #5303

@0xMH

Description

@0xMH

Plugin name and version: os-caddy (current master)

Describe the bug

When a non-wildcard domain entry like blog.example.com has Dynamic DNS enabled, the Caddyfile template generates an incorrect dynamic_dns domains block:

dynamic_dns {
    domains {
        blog.example.com @
    }
}

The caddy-dynamicdns module treats the first field as the DNS zone name. Since blog.example.com is not a DNS zone (the zone is example.com), the DNS provider lookup fails silently and the record never gets updated.

The correct output should be:

dynamic_dns {
    domains {
        example.com blog
    }
}

Steps to reproduce

  1. Create a domain entry with FromDomain set to blog.example.com (not a wildcard, not a bare domain)
  2. Enable Dynamic DNS on this entry
  3. Reconfigure Caddy
  4. Check the generated Caddyfile - the dynamic_dns block will have blog.example.com @ instead of example.com blog

Root cause

In the Caddyfile template (line 155), the else branch for non-wildcard domain entries appends cleanedDomain + " @" without checking if the domain is a subdomain (has more than 2 parts). The subdomain loop (lines 161-164) already has the correct split logic but it only applies to entries created as subdomains under a wildcard parent.

Current workaround

Create a wildcard parent domain (*.example.com) and nest subdomains under it. This forces the subdomain template path which correctly splits the zone and record name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportCommunity support or awaiting triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions