Custom domains for SaaS customers: CNAMEs and certificates
Short answer: To let customers use their own domain, such as book.theirsalon.ie, for a portal or booking page your SaaS hosts, have them add a CNAME record pointing at a hostname you control, verify they own the domain, then issue a TLS certificate for it automatically through an ACME provider like Let's Encrypt. Route requests by hostname to the right customer, guard against people claiming domains they don't own, and plan for apex domains, which can't normally use a CNAME.
Why customers ask for it
A booking page at yourapp.com/salon-123 works, but customers want their own brand in the address bar: it looks more trustworthy, it's easier to put on a card, and it keeps links working if they ever move. For a SaaS selling to small businesses, custom domains are often a paid-plan feature worth building well.
The work has four parts: DNS, ownership verification, certificates and routing.
Part 1: DNS with a CNAME
The simplest setup asks the customer to create a CNAME record on a subdomain they own, pointing at a hostname you control:
book.theirsalon.ie. CNAME customers.yourapp.example.
A CNAME makes the customer's name an alias of yours, so when you change server IP addresses, their domain follows automatically. Give each customer clear, copyable instructions, and ideally a check button that looks up the record and tells them whether it's correct.
The apex domain problem
Customers often want the bare domain, like theirsalon.ie, not a subdomain. The core DNS standard, RFC 1034, says that if a CNAME record exists at a name, no other data should be present there. The apex of a domain always has other records, such as its name server and SOA records, so a standard CNAME can't go there.
Options:
- Recommend a subdomain, like
book.orwww., and have the apex redirect to it at the customer's DNS or registrar. - Support providers' alias records, sometimes called ALIAS, ANAME or CNAME flattening, which some DNS hosts offer at the apex.
- Publish fixed IP addresses for an A record, which works but makes it harder for you to change infrastructure later.
Most SaaS products recommend a subdomain and document the apex workarounds.
Part 2: verify ownership
Without verification, someone could add bigbrand.ie to their account before the real owner does, or keep a domain a customer has since pointed elsewhere. Common approaches:
- Ask for a TXT record with a token you generate, such as
_yourapp-verify.book.theirsalon.ie, and check it before activating. - Treat a correctly pointed CNAME as proof, combined with only issuing certificates once DNS resolves to you.
Re-check periodically. If a customer's domain stops pointing at you, stop serving it and alert them, rather than keeping a stale configuration.
Part 3: certificates automatically
Every custom domain needs its own valid TLS certificate. Doing this by hand doesn't scale, so use ACME, the protocol Let's Encrypt and other certificate authorities support.
Let's Encrypt's documentation on challenge types explains the options for proving control of a domain:
- HTTP-01: your server serves a token file over HTTP on port 80. It's the most common choice and works well for custom domains once the CNAME points at you. It can't issue wildcard certificates.
- DNS-01: a TXT record proves control. It supports wildcards, but needs API access to the domain's DNS, which you won't have for customers' domains.
- TLS-ALPN-01: the check happens over TLS on port 443, useful when port 80 isn't available.
For SaaS custom domains, HTTP-01 or TLS-ALPN-01 are the practical choices.
Some web servers automate this per hostname. Caddy's documentation describes On-Demand TLS, which obtains a certificate during the first TLS handshake for a new domain, and strongly recommends an "ask" endpoint that the server calls to confirm a domain is allowed before requesting a certificate. That check is essential: without it, anyone pointing a domain at your server could trigger certificate requests.
Watch the certificate authority's limits
Let's Encrypt publishes rate limits, including a limit on new certificates per registered domain over a rolling seven-day period. Limits are per customer domain, so they rarely bite for normal sign-ups, but bugs that request certificates repeatedly can hit them. Cache certificates, renew ahead of expiry, back off on failures and check the current limits page when designing.
Part 4: route by hostname
Once traffic arrives, your app reads the Host header, looks up which customer owns that domain and serves their content. Practical points:
- Store verified domains in a table with the customer ID and status.
- Normalise hostnames to lowercase and strip trailing dots before lookup.
- Return a clear "not configured" page for unknown hosts, not someone else's content.
- Set canonical URLs so search engines index the customer's domain, not duplicates on your default address.
Help customers through the setup
Most support tickets come from DNS confusion. Reduce them with:
- Instructions for common registrars and DNS hosts.
- A live status check: DNS found, verified, certificate issued.
- A note that DNS changes can take time to appear, depending on caching.
- An email when the domain goes live, or when it breaks.
A worked example
Imagine a hypothetical Kilkenny booking-software company whose salon and clinic customers kept asking for their own domains. The team asked customers to add a CNAME on a subdomain, verified it with a TXT token, put a server with on-demand certificates and an "ask" endpoint in front of the app, and routed by hostname. A status panel showed each step. Customers wanting the bare domain were shown how to redirect it to book. at their registrar.
FAQ
Can I use one certificate for all customer domains?
Not practically. Each domain needs a certificate covering its own name, issued separately.
What if the customer uses a CDN in front?
It can work, but certificate and verification steps may need adjusting. Test that setup specifically.
Do I need dedicated IP addresses?
No. Modern TLS uses SNI, so one IP can serve certificates for many domains.
If you're planning custom domains for your SaaS customers, tell us about your hosting setup. For an overview of the web apps and first product versions we build, see web app development in Vienna.