Default URLs and custom domains

Reading · 5 min · Module 6, lesson 1 of 550 min left in this module

Module 6 · Domains and SSLLesson 1 of 5

Goal: Add your own domain to a web service, and know what happens to its default URL.

3:45 · captions and chapters · narrated with an AI-generated voice
Transcript

Narration uses an AI-generated voice.

[00:00] Where we're going

By the end of this video, you'll know where your service's default address comes from, and how to put your own domain in front of it. You'll also see why your domain ends up pointing at that default address.

[00:12] The default URL

Here's hello-web, a web service we've just deployed. It's Running. Right next to that is its default URL, on computesphere dot app. Every web service gets one as soon as it's deployed.

Let's read it. It starts with d, and a dash. Then the service's name, hello-web. Then the first eight characters of its deployment ID. Here's that ID, on the Overview. The deployment ID stays the same across redeploys and rollbacks. So the address does too.

It's HTTPS from the start, with a valid certificate. Ask it from a terminal, and it answers. Two hundred. This is the address you've tested against so far.

[01:00] Words you'll need

Before we add a domain, four words you'll need. First, DNS. It's the internet's phone book. It turns a name like app dot example dot com into the place that serves it. Second, your DNS provider. That's whoever holds that entry for your domain. Often, it's where you bought the domain. Third, a CNAME record. It says, this name is another name for that one. Here, app dot example dot com becomes another name for your default URL. And fourth, the apex. That's the bare domain, example dot com, with nothing in front.

[01:41] Add a custom domain

Now, the console. Adding a domain opens this dialog. Enter the domain. We'll use app dot example dot com, a name set aside for examples. Leave Certificate on Automatic. ComputeSphere issues and renews it for you. Then read the DNS Configuration table. It lists the records to create at your DNS provider. Here, it's one CNAME. Its name is app, and its value is your default URL.

[02:13] From the terminal

You can also do this from the terminal. One command adds the domain to the deployment. Ask for its status, and it's pending DNS. It stays that way until you create those records at your DNS provider. That's the next lesson.

Once the records are in place, ComputeSphere checks them. It issues the certificate. And the domain turns Active. Your domain's record points at the default URL, so both names reach the same service.

[02:46] Apex and www

One more thing. People type both example dot com, and www dot example dot com. So adding one sets up the other too. Here, we add www. And the list shows example dot com as well, each with its own status. Each one needs its own DNS record.

And the default URL? It stays on. Once a custom domain is serving, you can turn it off, on the Networking card in Settings. Until then, the switch stays on.

[03:19] Recap

So, a quick recap. Every web service gets a working HTTPS address, as soon as it's deployed. A custom domain puts your own name in front of the same service. And your domain's DNS record points at that default address. Next, we'll create those records at your DNS provider. I'll see you there.

Key idea

Every web service gets a working HTTPS address on computesphere.app as soon as it's deployed. A custom domain puts a name you own in front of the same service, and the default address is what your domain's DNS record points at.

The default URL

https://d-hello-web-3f9c2a71.computesphere.app

It's d-, the service's name, and the first eight characters of its deployment ID. The deployment ID stays the same across redeploys and rollbacks, so the address does too. It has a valid certificate from the start, and it's the address you've tested against so far.

Words you'll need

  • DNS is the internet's phone book: it turns a name like app.example.com into the place that serves it.
  • Your DNS provider is whoever holds that phone book entry for your domain, set by its nameservers. It's often your registrar (where you bought the domain), sometimes Cloudflare or your cloud.
  • A CNAME record says “this name is another name for that one”.
  • The apex is the bare domain, example.com, without anything in front.

Adding a custom domain

  1. Open the service. On its Overview, find the Custom domain card and choose Add domain.
  2. Enter the domain, for example app.example.com.
  3. Leave SSL certificate on Automatic; ComputeSphere issues and renews it (lesson 5.6.3).
  4. Read the DNS configuration table under the field. It lists the records to create at your DNS provider.
  5. Choose Add domain.

The domain then waits at Waiting for DNS until you create those records (next lesson). Once they're in place, ComputeSphere checks them, issues the certificate, and the domain turns Active.

Apex and www come as a pair

People type both, so adding example.com also sets up www.example.com, and the other way round. Both appear in the Custom domain card with their own status, and each needs its own DNS record.

Several domains, and turning the default URL off

A service can carry several independent domains, each with its own records, certificate and status. A domain belongs to one service at a time; adding one that's attached elsewhere is refused with this domain is already in use by another service.

Once a custom domain is serving, you can turn the default URL off so the service answers only on your domain. The switch is on the Networking card in the service's Settings, and stays on until a custom domain is active.

From the terminal, with the deployment ID from csph deployments list:

csph deployments domains add app.example.com --deployment <id>
csph deployments domains dns app.example.com --deployment <id>
csph deployments domains get app.example.com --deployment <id>

dns prints the records to create; get shows the domain's status, as pending_dns while it waits for your records. The account's Domains page lists the same domain with its certificate as Requested until it's issued.

Check yourself

You redeploy hello-web with a new image. What happens to its default URL?