
Ask HN: How to support many domain names on a platform? - harrisreynolds
Hey! Does anyone here have experience supporting multiple custom domains on a single platform?  I want to support this with Webase and I have some ideas on how to do it, but curious if anyone here has solved that before?<p>Ideally the solution would support:<p>1) updating webserver config to know about new domain via an API and 
2) Updating DNS to know about the domain via an API and
3) Need to support SSL (LetsEncrypt)<p>And I&#x27;d like to automate all of this so a person does not need to touch it.<p>Thanks for any insight!
======
JackWritesCode
I wrote about this a few days ago on how I did this with Caddy:
[https://laravel-news.com/unlimited-custom-domains-vapor](https://laravel-
news.com/unlimited-custom-domains-vapor)

~~~
harrisreynolds
Awesome. I’m looking forward to reading this given you’ve just finished
thinking through all these details.

------
tlack
I've had to do this a few times and I'm not sure there's ever a single "best
way to do it"

1) The webserver can be configured to respond for any domain. Then your
application software can look at the HTTP host header to decide which client
you are working with.

2) I've used DJBDNS in the past because it's very easy to generate the
necessary config files and if I recall didn't require restart (since the
config is stored in a "database file" \- binary flat file in this case). You
could also try dynamically rewriting the BIND config and restarting it via a
cronjob every 10 minutes.

3) No clue here but it should be easy to automate

The worst part of all this is having to write the DNS docs for users so they
can point their domain correctly. DNS is incredibly confusing to setup for
"mere mortals" due to the many different registrars with varying DNS editing
capabilities. Caching and IP address perplexity makes it worse.

------
mholt
Caddy is designed for precisely this use case:
[https://caddyserver.com](https://caddyserver.com)

It can handle thousands of domains easily, with Let's Encrypt (or any other
ACME CA), even if you don't control your customer's domains.

Hit up the forums if you have any questions:
[https://caddy.community](https://caddy.community)

------
frnkng
1 and 3: use caddy. I prefer the config format of caddy over the toml files
used by Traefic. and caddy 2 even has an api for that Purpose. Caddy is rock
solid.

2: depending on the use case you may get away with an wildcard/catch all dns
entry. If customers shall bring their own domain name, they will have to
create an cname record anyway.

------
harrisreynolds
A big thanks for all the comments! Looking at Caddy now. Hoping I can put it
in front of a Rails app fairly easily.

------
hakanderyal
You can use Traefik for 1 and 3, and Cloudflare for 2.

