Docs cipi.yml Web panel API MCP Guides Compare GitHub Telegram channel
  1. Docs
  2. Domains & SSL
  3. Wildcard domains

Wildcard domains

Tenant subdomains with a wildcard certificate.

Domains & SSL

One app answering on every <tenant>.myapp.com, with one certificate for all of them. It takes two separate things:

PartHowNote
Routingcipi alias add myapp '*.myapp.com' (or a wildcard primary)Works with any DNS
Certificatecipi ssl install myapp --dns=cloudflareLet's Encrypt issues wildcards over DNS only; Cipi automates Cloudflare

Which setup is yours#

Your DNSCertificateCloudflare SSL/TLS mode
Cloudflare, proxied (orange) — best for SaaSLet's Encrypt via DNS-01, or Cloudflare Origin CAFull (strict)
Cloudflare, DNS only (grey)Let's Encrypt via DNS-01not used
Another providerMove DNS to Cloudflare (free), list the subdomains, or bring your own certificate—
Cloudflare Tunnel (cipi zt)Not needed: Cloudflare terminates HTTPSset by the tunnel

With Cloudflare, step by step#

Step 1 of 5DNS records

In Cloudflare, create A @ and A * records pointing at the server's IP. The * record sends every subdomain to the server.

bash
cipi ssl dns set --token=YOUR_CLOUDFLARE_TOKEN
cipi alias add myapp '*.myapp.com'
cipi ssl install myapp --dns=cloudflare
cipi ssl status
curl -sI https://tenant1.myapp.com | head -1

The token needs only Zone → DNS → Edit on that zone. Renewals happen by themselves with the same token. --wildcard adds myapp.com + *.myapp.com to the certificate even without a wildcard alias (handy for many explicit subdomains); it does not route anything.

Cloudflare errors decoded#

You seeCauseFix
ERR_TOO_MANY_REDIRECTSSSL/TLS mode Flexible (globally or in a rule)Full (strict)
525 SSL handshake failedNo app has that hostname, or it has no certificate yetAdd the alias / issue the certificate
526 Invalid SSL certificateThe certificate doesn't cover the hostnamecipi ssl status, then reissue
Deep names fail (a.b.myapp.com)Universal SSL covers one levelKeep tenants one label deep

Without Cloudflare#

OptionWhen
Move DNS to Cloudflare, records "DNS only"Recommended: free, traffic unchanged
List each subdomain as an alias, HTTP-01Few, known tenants (max 100 names per certificate)
Bring your own certificate with your provider's certbot pluginRoute 53, DigitalOcean, OVH, Gandi…
bash
# bring your own: name the certificate after the app's primary domain
apt install python3-certbot-dns-route53
certbot certonly --dns-route53 -d myapp.com -d '*.myapp.com' --cert-name myapp.com
cipi alias add myapp '*.myapp.com'    # Cipi finds and serves it

Don't run cipi ssl install on that app afterwards: it would reissue over HTTP without the wildcard.

Multi-tenant tips#

  • Exact names win: with *.myapp.com on one app, api.myapp.com can still be another app.
  • Unknown hosts are closed by the default server, not sent to your tenant resolver.
  • Laravel: resolve the tenant from the Host header; set SESSION_DOMAIN=.myapp.com only to share logins across subdomains.
  • Need isolation per tenant (own database, backups, server)? Create one Cipi app per tenant through the API instead.