Software Engineering :: Web :: Development :: HTTP :: Server :: Caddy :: Configuration :: Caddyfile :: Example :: Wildcard certificates
⪼ Made with 💜 by Polyglot.
If you need to serve multiple subdomains with the same wildcard certificate, the best way to handle them is with a Caddyfile like this, making use of the handle directive and host matchers:
*.example.com {
tls {
dns <provider_name> [<params...>]
}
@foo host foo.example.com
handle @foo {
respond "Foo!"
}
@bar host bar.example.com
handle @bar {
respond "Bar!"
}
# Fallback for otherwise unhandled domains
handle {
abort
}
}