Point a domain at your site with Fastly
Tags: cdn, tls, domain, dns
Published: 2023-11-17 11:39:52

---
title: Point a domain at your site with Fastly
published: true
description: Use free TLS and CDN to point your domain at a site with Fastly
tags: cdn, tls, domain, dns
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-11-16 13:04 +0000
---

Got a shiny new domain you want to point at a site or application you have hosted somewhere on the web? If you’re anything like me, you’ll have a bunch of domains you thought sounded cool and that are lying around doing nothing. Well the good news is that you can use Fastly TLS and CDN to point the domain at your site completely for free. Follow the steps below!

What you’ll need:

* Your new domain and access to the DNS settings (these will be where you registered the domain)

That’s it!

## Sign up for a free Fastly account

Jump over to [fastly.com/signup](https://www.fastly.com/signup) – fill out your details and get signed up.

We are going to get two things from Fastly:

* A **Delivery service** to serve our origin website through the CDN
* A **TLS certificate** to send traffic to the domain through the Fastly service

We get a few other benefits by default:

🤑 **Caching** – making the site fast and maybe even saving us on costs 
🔐 **Security** – improving site discoverability as well as safety 
📊 **Observability** – showing us what’s happening with site traffic 

## Create a service

In your Fastly account, click **Create service** and choose **CDN**.

![Create a CDN service](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kmwnp1cy5uae0sm814cu.png)

* Give your service a **name** of your choice – this is just so that you can identify it in your Fastly account.
* Enter your **domain** (it's easiest if you include the www – if you need to use an apex domain, like `suesmith.lol` instead of `www.suesmith.lol` you'll find details in [the Fastly docs](https://developer.fastly.com/learning/concepts/routing-traffic-to-fastly/#configure-dns-records-with-your-dns-provider)).

![Enter name and domain](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sypoovdbc6b6r0fejg5e.png)

* Enter your **origin** – for me this is a Glitch site so it has a `.glitch.me` address.
* Try the **recommended settings** in their default state – if you have issues later you can always toggle them off.

![Origin and defaults](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qbmky1x1ky5t0xwqi8i.png)

**Activate** your service!

## Create a TLS certificate

OK now we need to grab a TLS certificate. In the top menu in your Fastly account, click **Secure**, then **Manage certificates** under **TLS Management**. 

![Manage TLS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yl8snplfd0qivop7ftxa.png)

In TLS management, click **Get started**. _If you have a TLS certificate in your account already you’ll click **Secure another domain** instead._

We’re going to use a Fastly-supplied certificate. Enter your domain name and click **Add**.

![Add your domain](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3vhbitjv4wru6xcghpkx.png)

Fastly will add your domain as the **Common name**. With **Certainly** selected, click **Submit**.

![Submit TLS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4909ipjdrirsboxv8gey.png)

## Verify your domain

When you submit your new TLS certificate, Fastly will provide the details to verify your domain.

![TLS pending validation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c2jfjitgyxhqvjlzj4q.png)

Click **Verification options**.

_This is where things can get a bit unpredictable depending on your domain registrar! The instructions below should work for most providers._ 🤞

Copy the **ACME DNS challenge** CNAME and value (hit the clipboard icon for the value). The CNAME will be `_acme-challenge` followed by your domain name, and the address to point the DNS record at will be a string of characters followed by `fastly-validations.com`.

![TLS verification](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bb0z55zmor4aoby8m6wx.png)

In your domain registrar account (wherever you registered the domain), navigate to the **Custom DNS settings**. We’re going to add two new **CNAME** records, one to verify the domain for the TLS certificate, and one to route the domain traffic to Fastly. 

First let’s verify the domain: 

* Set the _host_ name to the address from the TLS info that’s something like `_acme-challenge` followed by your domain name (note that for some domain management tools you only need to enter the subdomain up to `www` and they add the rest)
* Set the _address_ (sometimes called _data_ or _content_, it’ll expect an IP address) to the value you copied that includes `fastly-validations.com` 

![DNS example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgh85y3csiv4yqlsl28w.png)

Save your new record. With any luck back in your Fastly account the domain will pass validation!

![Domain passing validation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ud0yfrcnlutlshxlvf9q.png)

Shortly after this the certificate will be issued. 

![Certificate issued](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ohcprk6qincnfzcz6io.png)

## Point your domain at Fastly

OK we’re almost there! Now you just need to point your domain to Fastly. This is what will happen once your domain settings are in place:

* Someone visits the domain
* The domain points at Fastly
* Fastly finds the service with the domain in it
* Fastly sends the visitor a response based on the service config – at first it’ll be the origin host response (for me this will be the Glitch site), then later it might be cached, meaning Fastly doesn’t even need to visit the origin

🚨 ***Do not complete this step until you’re ready to send visitors to your domain to the origin in your Fastly service – this is the point at which your domain traffic will start moving through Fastly.***

First you’ll need to grab the correct CNAME to point your domain at – in your Fastly account, navigate to (**Secure > TLS Certificates >**) **Domains** and **View details** for the domain. Copy the **CNAME record** address – it will be a single character followed by `.sni.global.fastly.net`.

![CNAME details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kn8uu3899clkz1fn9h3o.png)

🔋 To enable IPv6, append `dualstack.` to the start of your address.

Back in your domain registrar DNS settings, add another CNAME record, this time for the `www` version of your domain, pointing at e.g. `dualstack.t.sni.global.fastly.net` (adjust that single character to match your certificate). _If you already have a CNAME record for `www` you'll need to replace it with the one for your Fastly service._

![CNAME pointing to Fastly](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2klv5go0ep4tm7q1n0rp.png)

💡 *If you have an existing CNAME record for the domain, you may want to reduce the TTL value before making a change, to speed up the process of sending your traffic through Fastly – this also helps if things go wrong and you need to make further changes.*

Give it some time for your changes to propagate (at least the TTL value, which is in seconds) and you should soon see the origin site you pointed your Fastly service at when you visit the domain you registered!

![The site being served through Fastly](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wysnaxujzbft932jsfi2.png)

Well check that out, it’s my Glitch in Bio site being served through a Fastly cache node in Manchester and at my daft domain. 🎉

🛠️ _Use the terminal command `dig <your-domain.com>` to check what’s happening with the DNS while you wait for changes to propagate._

🛟 If you get stuck and can’t get your domain to connect up, pop over to [community.fastly.com](https://community.fastly.com/) and ask for help. There will almost certainly be someone who has encountered your issue before, and otherwise your post will help future developers!

## Next steps

The Fastly docs have a ton of additional info on using the CDN and TLS for your site:

* [Introduction to Fastly's CDN](https://docs.fastly.com/en/fundamentals/fastly-cdn)
* [Routing traffic to Fastly](https://developer.fastly.com/learning/concepts/routing-traffic-to-fastly/)

👀 Check out the **Observability** stats for your site in your Fastly account.

🍬 If you don’t have a site or host yet but want to point your domain somewhere, grab a Glitch in Bio remix from [glitch.new/links](https://glitch.new/) and use its `.glitch.me` address as your service origin – you can easily switch it out later if you want to point your domain somewhere else!

🚨 [**Update 19 December 2023: You should have your own domain**](https://dev.to/fastly/you-should-have-your-own-domain-23mp)