TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How to support many domain names on a platform?

6 pointsby harrisreynoldsalmost 5 years ago
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!

6 comments

JackWritesCodealmost 5 years ago
I wrote about this a few days ago on how I did this with Caddy: <a href="https:&#x2F;&#x2F;laravel-news.com&#x2F;unlimited-custom-domains-vapor" rel="nofollow">https:&#x2F;&#x2F;laravel-news.com&#x2F;unlimited-custom-domains-vapor</a>
评论 #23508844 未加载
tlackalmost 5 years ago
I&#x27;ve had to do this a few times and I&#x27;m not sure there&#x27;s ever a single &quot;best way to do it&quot;<p>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.<p>2) I&#x27;ve used DJBDNS in the past because it&#x27;s very easy to generate the necessary config files and if I recall didn&#x27;t require restart (since the config is stored in a &quot;database file&quot; - binary flat file in this case). You could also try dynamically rewriting the BIND config and restarting it via a cronjob every 10 minutes.<p>3) No clue here but it should be easy to automate<p>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 &quot;mere mortals&quot; due to the many different registrars with varying DNS editing capabilities. Caching and IP address perplexity makes it worse.
mholtalmost 5 years ago
Caddy is designed for precisely this use case: <a href="https:&#x2F;&#x2F;caddyserver.com" rel="nofollow">https:&#x2F;&#x2F;caddyserver.com</a><p>It can handle thousands of domains easily, with Let&#x27;s Encrypt (or any other ACME CA), even if you don&#x27;t control your customer&#x27;s domains.<p>Hit up the forums if you have any questions: <a href="https:&#x2F;&#x2F;caddy.community" rel="nofollow">https:&#x2F;&#x2F;caddy.community</a>
frnkngalmost 5 years ago
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.<p>2: depending on the use case you may get away with an wildcard&#x2F;catch all dns entry. If customers shall bring their own domain name, they will have to create an cname record anyway.
harrisreynoldsalmost 5 years ago
A big thanks for all the comments! Looking at Caddy now. Hoping I can put it in front of a Rails app fairly easily.
hakanderyalalmost 5 years ago
You can use Traefik for 1 and 3, and Cloudflare for 2.