How to issue certs for www & domain with tls on demand?

I run caddy for multiply domains using tls on demand.
It works for my test domains, but this configuration generate separate certs for https://www.testudo.top/ and https://testudo.top/
On old nginx+certbot server was enought just one cert for domain with and without www.

{
    on_demand_tls {
        ask      http://localhost:5555/check
    }

    storage redis {
        host localhost
        port 6379
        db 0
        prefix caddy_  # Optional: prefix for Caddy keys in Redis
    }
}

https:// {
    tls {
        on_demand
        dns powerdns {env.POWERDNS_SERVER_URL} {env.POWERDNS_API_TOKEN}
    }
    reverse_proxy localhost:3000
}

We don’t support multi-SAN certificates for good reasons. See the section “Use one name per certificate” here:

2 Likes