Guides

Add a custom domain

Serve an app under your own domain, with HTTPS.

Every public app has an address under lilylabs.app. This guide adds your own domain to an app, for example shop.example.com. Domains explains the states a domain passes through.

Before you start

  • A deployed, public app. The examples use the app copperfox.
  • Access to the DNS settings of your domain.
  • A subdomain such as shop.example.com or www.example.com. A bare domain such as example.com only works if your DNS provider supports ALIAS records or CNAME flattening.

Steps

Add the domain to the app

  1. Open the app and select the Domains tab.
  2. Select Add domain and enter the name, for example shop.example.com.
  3. The domain opens a setup with four phases: Domain, DNS records, Certificate and Live. It lists the two DNS records with Host and Value. Copy both.
lly domain copperfox add shop.example.com

The command prints the two DNS records to create:

  DNS records
  Type   Name                           Value                   Purpose
  CNAME  shop.example.com               copperfox.lilylabs.app  routing
  TXT    _lily-verify.shop.example.com  lily-verify=dv_1        verification

Create the two DNS records

In the DNS settings of your domain, create both records exactly as printed. The CNAME record routes traffic to the app. The TXT record proves that the domain is yours.

Wait for verification

LILY checks pending domains every 30 seconds. DNS changes can take a few minutes to become visible.

Select Check in the setup. Each record shows Found, Missing or Wrong value. Once ownership is confirmed, the certificate is issued, which usually takes a few minutes.

lly domain copperfox check shop.example.com

To wait in the terminal until the domain is verified, for up to 10 minutes:

lly domain copperfox add shop.example.com --wait

Check that it worked

The domain moves from Pending to Verified and then to Active. Once it is Active, https://shop.example.com opens your app with a valid certificate.

Hostname                Kind    State    Since
copperfox.lilylabs.app  slug    active   2d ago
shop.example.com        custom  active   1m ago

If it does not work

What you seeCauseFix
The domain stays PendingThe TXT record is missing, has a typo or is not visible yetCompare the record with the output of lly domain copperfox check shop.example.com and wait a few minutes. See The domain stays pending.
lly domain add exits with code 5The hostname is already assigned to another appRemove it from the other app first
--wait exits with code 6The domain was not verified within 10 minutesCheck the records, then run lly domain copperfox check shop.example.com
Your DNS provider rejects the CNAMEThe domain is a bare domain such as example.comUse a subdomain, or an ALIAS record if your provider offers one
The setup says the app is privateA private app cannot be reached by a domain, so only the TXT record is checkedMake the app public. See Expose a port
A wildcard such as *.example.com is rejectedWildcards are not supportedAdd each hostname separately

More messages and their fixes: Troubleshooting.

Use an agent

Add the custom domain shop.example.com to my LILY app "copperfox".
Run `lly domain copperfox add shop.example.com` and show me the two DNS records it prints.
Do not change DNS yourself. After I confirm the records exist, run
`lly domain copperfox check shop.example.com` until the state is active, then tell me.

Next steps

On this page