Domains
Serve production on your own domain, apex or wildcard, with a Let’s Encrypt certificate the router gets and renews by itself. Domains can also follow a branch or redirect.
Add a domain
Open the project’s Domains page, or use the CLI. add prints the DNS records the domain needs.
forkrail domains add shop.example.com storefront # a subdomainforkrail domains add example.com storefront # the apexforkrail domains add '*.example.com' storefront # a wildcardforkrail domains add www.example.com storefront --redirect example.com --status 308forkrail domains add staging.example.com storefront --branch stagingforkrail domains ls storefront # each domain and its certificateforkrail domains inspect shop.example.comforkrail domains check shop.example.com # look at DNS again nowforkrail domains update www.example.com --productionforkrail domains rm shop.example.comDNS records
| Record | For |
|---|---|
shop.example.com CNAME storefront.<your forkrail domain> | A subdomain |
example.com A <the install’s address> | The apex (@), which can’t be a CNAME |
_acme-challenge.shop.example.com CNAME <hash>._acme.<your forkrail domain> | Optional: the certificate before DNS moves. Required for a wildcard. |
The record must be DNS only (grey cloud). A proxied record shows invalid (proxied), because the router needs to see the visitor and answer the certificate challenge itself.
Certificates
The router gets each domain a Let’s Encrypt certificate, proving the domain is yours the first way that works:
- Cloudflare: the domain is in a Cloudflare zone your install’s token can edit. The certificate arrives within a minute.
- Delegated challenge:
_acme-challenge.<domain>is a CNAME to the addressaddprinted. This works before the domain points at forkrail, and it’s the only way a wildcard gets a certificate. - HTTP: the domain already points at forkrail.
Before asking Let’s Encrypt, the router checks the domain’s own nameservers, so a domain whose DNS isn’t ready yet never wastes a validation attempt. It looks again every 30 seconds (every 5 minutes after a day); with the Domains page open it checks every few seconds. Certificates renew with a third of their 90 days left, and you’re emailed if one has under 14 days left.
Redirect domains and branch domains
- Redirects: a domain can redirect (301, 302, 307 or 308) to another of the project’s domains, keeping the path and query. The dashboard offers the
wwwpair whenever you add an apex domain. - Branches: a domain with
--branch stagingserves the newest ready preview of that branch, like its branch URL, and moves with each push. It answers 404 until the branch has a ready preview. - Wildcards:
*.example.comcovers one label below the domain.
Move a domain without downtime
- 1Add the domain
On a Cloudflare zone your token edits, the certificate comes within a minute. Elsewhere, add the
_acme-challengeCNAME it printed first.forkrail domains add api.example.com my-api - 2Wait for the certificate
Until
domains lsshowsissued.forkrail domains ls my-api - 3Test it before DNS moves
Send a request straight to the router while DNS still points at the old host.
curl --resolve api.example.com:443:<router address> https://api.example.com/health - 4Lower the TTL
Set the record’s TTL to 60 seconds, keeping its target, and wait out the old TTL.
- 5Point the record at forkrail
Change the CNAME to
<project>.<your forkrail domain>. To go back, point it at the old host again.
forkrail domains rm stops serving a domain within seconds, so move its DNS away first. Owners and members change domains; developers can ask for a check.