Setting Up a Custom Domain
You can point your own domain to a container running on Bahriya. This guide walks through the steps to configure a custom domain with HTTPS.
You can point your own domain to a container running on Bahriya. This guide walks through the steps to configure a custom domain with HTTPS.
Prerequisites
- A container deployed on Bahriya with at least one region active.
- A domain you control with access to its DNS settings (at your domain registrar or DNS provider).
Step 1: Add the domain to your container
In your container's networking section, add your domain — for example, app.example.com. You can attach up to 5 custom domains per container. The first is included; each additional domain is billed at $2.50/month, metered per minute (60-second minimum, rounded up).
Choose a DNS mode that determines how traffic is routed:
| Mode | How it works | DNS record you create |
|---|---|---|
| None | Traffic goes directly to each region. No Bahriya-managed DNS. | A/AAAA records pointing to each region's gateway IP |
| Round-robin | Bahriya distributes traffic evenly across your active regions. | CNAME to your container's vanity hostname |
| Geo | Bahriya routes users to the nearest region based on their location. | CNAME to your container's geo hostname |
Step 2: Create DNS records at your provider
For round-robin or geo mode
Create a CNAME record at your DNS provider:
app.example.com CNAME <your-container-handle>.<dns-zone>The exact CNAME target is shown in your container's networking settings in the console.
For "none" mode
Create A records pointing to the gateway IP of each region where your container is deployed. The gateway IPs for each region are listed in the Regions documentation.
If using a root domain (apex)
Most DNS providers do not support CNAME records on root domains (example.com without a subdomain). Options:
- Use a subdomain instead (
app.example.com,www.example.com). - Use a DNS provider that supports CNAME flattening or ALIAS records (e.g. Cloudflare, DNSimple, Route 53).
Step 3: TLS certificate
Bahriya automatically provisions and renews a TLS certificate for your custom domain once the DNS records are in place. This typically takes a few minutes after the DNS change propagates.
You do not need to upload your own certificate or manage renewals.
Step 4: Verify
Once DNS propagation is complete (usually a few minutes, can take up to 48 hours depending on your DNS provider and TTL settings), visit your custom domain in a browser. You should see your application served over HTTPS.
WWW redirect
For any apex domain you add (e.g. example.com), you can enable WWW redirect on a per-domain basis. When enabled:
- Requests to
www.example.comare redirected toexample.com. - The TLS certificate is automatically extended to cover the
wwwvariant alongside the apex. - You need to create DNS records for both
example.comandwww.example.com.
The toggle is only available for apex entries — www.example.com or sub.example.com cannot opt in.
Troubleshooting
"Not secure" or certificate error:
- DNS may not have propagated yet. Check with
dig app.example.comor an online DNS checker. - Ensure the CNAME or A record points to the correct target.
- Wait a few minutes for the TLS certificate to be provisioned.
Site not loading:
- Verify the DNS record type is correct (CNAME for round-robin/geo, A for none mode).
- Check that the container is running and healthy in the Bahriya console.
- If using a CDN or proxy (e.g. Cloudflare), ensure it is not interfering with the certificate provisioning. You may need to temporarily disable proxying.