I am trying to apply some configuration options that will apply to all subdomains via wildcard. For example, given sub.example.com, I want to apply configuration to all further subdomains in *.sub.example.com.
Now, I do have a block with *.sub.example.com, but it’s paired with *.example.com for wildcard certificates. I just want to apply configuration to *.sub.example.com, so I’ve tried creating a separate block for just that.
Note that I am not looking help for wildcard certs.
I believe that I might have to use matchers within the *.sub.example.com and *.example.com block, but I also am unaware how I should go about that.
2. Error messages and/or full log output:
If I create another block targeting just *.sub.example.com, caddy validate tells me:
Error: adapting config using caddyfile: ambiguous site definition: *.sub.example.com
Thanks for the information. I came to the same conclusion (re: only having one block per host) while waiting for an answer and eventually settled on something like:
Seems fine, but obviously that config as-is won’t actually do anything with the HTTP requests (you’re not routing them to a proxy or file server or whatever).