> ## Documentation Index
> Fetch the complete documentation index at: https://docs.boxlite.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Bring your own domain

> Connect your own subdomain to a Cloud box with DNS verification and managed HTTPS.

Use a subdomain you control, such as `app.example.com`, as the public address of your service. BoxLite verifies your DNS records and manages the HTTPS certificate. For a hostname provided by BoxLite, follow [Managed domain](https://docs.boxlite.ai/cloud/managed-domains.md).

## Before you start

Install the latest CLI in your local terminal:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -fsSL https://sh.boxlite.ai | sh
```

Create an [API key](https://docs.boxlite.ai/cloud/api-keys.md) in the [console](https://app.boxlite.ai), then sign in:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context app auth login \
  --url https://api.boxlite.ai --method api-key
```

Paste your key at the prompt. `app` is the saved context used throughout this guide. Use the same organization in the console and CLI.

## Bring your own domain

Use this route for a hostname you own, such as `app.example.com`. You need access to its DNS provider and an active organization subscription. The **Custom domain** option must be enabled for your deployment.

**1. Add your subdomain**

In the same organization, open **Domains → Custom domain → Add custom domain**. Enter your public subdomain and click **Get DNS configuration**.

Use an ASCII or Punycode subdomain, such as `app.example.com`. Apex domains such as `example.com` and wildcards such as `*.example.com` are not supported.

If you already started configuring this hostname, adding it again resumes that configuration. Delete an existing configuration before adding a different hostname when your slot is occupied.

**2. Add the three DNS records**

At your DNS provider, add every record shown in the console. Copy each **Name** and **Value** exactly; use the values generated for your configuration.

| Record | Purpose |
| - | - |
| Traffic CNAME | Routes your application subdomain to the BoxLite hostname shown in the console |
| Ownership TXT | Proves that you control the subdomain's DNS |
| Certificate authorization CNAME | Allows BoxLite to issue and renew the HTTPS certificate |

> [!NOTE]
>
> If you use Cloudflare, set **both CNAME records to DNS only**. If your DNS editor automatically appends the zone suffix, enter relative names and check the resulting full record names. Keep the certificate authorization record separate from the traffic record.

**3. Verify DNS and wait for HTTPS**

Return to BoxLite and click **Configured, verify**. Fix any failed DNS records, wait for the changes to propagate, and verify again.

After DNS verification succeeds, BoxLite continues setting up HTTPS. Wait until the status is **Ready** before binding a box. If HTTPS setup fails, click **Retry**. If the page shows **Setup completed** instead of **Ready**, check that your organization has an active subscription.

Keep all three DNS records after setup: routing and certificate renewal depend on them.

Set the verified hostname in your terminal, without a scheme, port, or path:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
DOMAIN='app.example.com'
```

Replace the example with your own hostname, then continue below.

Custom-domain configuration uses a separate allowance. An unfinished configuration occupies the slot; see [Domain allowances](https://docs.boxlite.ai/cloud/plans.md#domains-storage-and-images).

## Publish your service

Use the hostname saved in `DOMAIN` below.

**1. Choose the service to expose**

> [tab] Existing service
>
> Set the box ID or name and the port your service listens on **inside the box**:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> BOX='<YOUR_BOX_ID_OR_NAME>'
> PORT=29090
> boxlite --context app start "$BOX"
> ```
>
> Replace `29090` with your service's port. The service must listen on `0.0.0.0`, rather than only `127.0.0.1`.

> [tab] Try a sample server
>
> Create a box with an HTTP server as its saved startup command:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> BOX=$(boxlite --context app create \
>   --name domain-demo \
>   --auto-stop 0 --auto-delete 0 \
>   python:alpine python -m http.server 29090 --bind 0.0.0.0)
> PORT=29090
> boxlite --context app start "$BOX"
> ```
>
> The sample serves a directory listing. `--auto-stop 0` keeps it running until you stop it; request-triggered startup is optional.

**2. Open the port and bind the domain**

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context app network inbound "$BOX" enabled
boxlite --context app network tunnel "$BOX" "$PORT"
boxlite --context app domain bind "$DOMAIN" \
  --type box --box "$BOX" --port "$PORT"
```

The tunnel command registers the port for public access and prints its generated URL. The bind command gives that port your chosen hostname and prints its HTTPS URL.

All three pieces are required: inbound access, a public tunnel for the port, and the domain binding. Binding alone does not make a service public.

This is a public endpoint. If your service needs sign-in or API authentication, enforce it in the application.

**3. Open your fixed URL**

Open `https://<YOUR_FULL_DOMAIN>` in your browser, or request it from your terminal:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --fail --show-error \
  -H 'X-BoxLite-Skip-Preview-Warning: true' \
  "https://$DOMAIN/"
```

The header skips the preview notice for scripted requests; it does not grant access or bypass your application's authentication.

You should receive your service's response. For the sample server, look for **Directory listing for /**. Share this HTTPS address with your clients; they do not need the box ID or internal port.

## Manage the service

To move the domain to another box, prepare the new service and its public tunnel, then run `domain bind` again with the same hostname and the new box and port. This changes routing; it does not copy application data.

To stop routing the domain while keeping its configuration:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context app domain unbind "$DOMAIN"
```

Unbinding retains the hostname and its allowance. The generated tunnel URL remains accessible. To close public access to that port too:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context app network tunnel --revoke "$BOX" "$PORT"
```

If you created the sample box and no longer need it:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context app rm --force "$BOX"
```

Deleting the box does not release or clear its domain binding. Unbind first or point the domain to another box.

For idle stopping and request-triggered startup, see [Box lifecycle](https://docs.boxlite.ai/cloud/box-lifecycle.md#wake-on-access). Save the service as the box's startup command so it runs after a restart.

## Delete a custom domain configuration

To release the custom-domain slot, open the configuration under **Domains → Custom domain**, click **Delete**, then **Confirm deletion**.

Deletion stops new requests through that hostname and releases the configuration slot. You can then remove its three DNS records. The generated tunnel URL remains separate; revoke the tunnel as described above if you also want to close public access to the port.

## Troubleshooting

| Symptom | What to check |
| - | - |
| `domain_not_owned` | Confirm the full hostname and organization with `domain ls`, and complete domain setup before binding. |
| The URL returns `404` | Check the domain binding, inbound access, and the public tunnel for the bound port. |
| The app cannot be reached | Confirm it listens on `0.0.0.0` at the bound port. Test the generated tunnel URL first. |
| DNS verification fails or times out | Check all three names and values. For Cloudflare, set both CNAME records to **DNS only**. Wait for propagation and retry. |
| DNS passes but HTTPS is not ready | Wait for certificate setup; use **Retry** after an error. For **Setup completed**, check subscription eligibility. Bind only when **Ready**. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.