- Let's Encrypt with a wildcard certificate for mataroa.blog and all *.mataroa.blog domains
- Caddy's automated certificates for all user custom domains
You can see a few more details about this setup in the server playbook doc [1] and the Caddyfile [2]
[1]: https://github.com/sirodoht/mataroa/blob/master/docs/server-...
[2]: https://github.com/sirodoht/mataroa/blob/master/Caddyfile
Things get trickier if you want to handle this well for globally distributed servers, since you'll need to have a cluster of reverse proxies near or colocated to your app servers. That needs an anycast IP address to handle A records for apex domains, and usually you want them coordinating to share certs, cache, etc. efficiently. In that situation I'd recommend reaching for a paid service, since there can be a lot to build and maintain.
Source: I built approximated.app, which is a service that does all of that for you.
One thing I've been wondering that a lot of web platforms offer: how do you allow users to bring their custom domain with TLS? What's the tech behind that and how does the process work?