Working with domains

Domains are used to route requests to your service. You associate your domain names with your origin when provisioning a Fastly service, and you can add, edit, or remove domains from your service at any time.

Creating a domain

Follow the steps below to add a domain to your service:

  1. Log in to the Fastly web interface.
  2. From the All services page, select the appropriate service. You can use the search box to search by ID, name, or domain.
  3. Click the Edit configuration button and then select the option to clone the active version. The Domains page appears.

    the Domains page

  4. Click the Create domain button. The domain creation fields appear.

    the Create a Domain page

  5. Fill out the domain creation fields as follows:

    • In the Domain Name field, enter your domain name. The domain name is used to properly route requests to your website, and ensures that others cannot serve requests to that domain. For example, you could enter www.example.com, blog.example.com, or even use wildcards such as *.example.com.

    • In the Comment field, optionally enter a comment that describes the domain.

  6. Click the Add button. Your new domain appears in the list of domains.
  7. If you haven't already, add CNAME DNS records for your domain name to begin routing client traffic through Fastly services instead of directly to your origin.
  8. Click the Activate button to deploy your configuration changes.

Using the API

You can use Fastly's API to programmatically add domains to your service. To add a domain to your service, make the following API call in a terminal application:

1
curl -H "Fastly-Key: FASTLY_API_TOKEN" -X POST https://api.fastly.com/service/<service_id>/version/<version_id>/domain -d 'name=www.example.com'

The response will look like this:

1
2
3
4
5
6
{
  "comment": "",
  "name": "www.example.com",
  "service_id": "<service_id>",
  "version": <version_id>
}

Domain creation limits

We set a limit on the number of domains you can create per service by default. However, if you email support@fastly.com, we may be able to adjust this number for you by working with you to set up and fine-tune domain handling in your service.

Testing a domain

After you activate your service configuration, but before you change your DNS entries to send your domain to our servers, you can check to see how your service is pulled through our network. Testing your domain can help you identify DNS issues or problems with your Fastly configuration.

Using the web interface

To use the web interface to test your domain on Fastly before you make a final CNAME change, follow the steps below:

  1. Log in to the Fastly web interface.
  2. From the All services page, select the appropriate service. You can use the search box to search by ID, name, or domain.
  3. Click the Edit configuration button and then select the option to clone the active version. The Domains page appears.

    the Domains page

  4. Click the Test domain link next to the domain you want to test.
  5. Verify that your website appears in a new tab in your web browser.

Using command line utilities

To use command line utilities to test your domain on Fastly before you make a final CNAME change, you would:

Determining the IP address of a Fastly POP

Use the nslookup or dig command to determine the IP address of a Fastly POP.

For example, running nslookup for nonssl.global.fastly.net returns:

1
2
3
4
5
6
7
$ nslookup nonssl.global.fastly.net
Server:		185.121.177.177
Address:	185.121.177.177#53

Non-authoritative answer:
Name:	nonssl.global.fastly.net
Address: 151.101.56.204

Find the IP address at the bottom of the nslookup response. In this example, it's 151.101.56.204.

Alternatively, running dig for nonssl.global.fastly.net returns:

1
2
3
4
5
6
7
8
9
10
11
12
13
$ dig nonssl.global.fastly.net

; <<>> DiG 9.8.3-P1 <<>> nonssl.global.fastly.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35146
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;nonssl.global.fastly.net.	IN	A

;; ANSWER SECTION:
nonssl.global.fastly.net. 30	IN	A	151.101.56.204

The IP address (A record) is in the ANSWER SECTION of the dig results: 151.101.56.204.

Modifying your hosts file

You can temporarily add a static IP address and domain Host entry to the hosts file on your computer. For example, if the domain you are testing is www.example.com and one of the IP addresses returned by nslookup or a dig command is 151.101.56.204, you would add this entry to the file:

1
151.101.56.204 www.example.com

and save the changes.

Testing your domain

Test your domain to see how Fastly pulls it through our network by restarting your browser if it's already running, and then typing your domain in the address field. You should now see the updated domain in the address field indicating requests are being sent to the Fastly POP.

Alternatively, you can test the domain using a ping command to verify that your domain is being served by a Fastly POP address. In this case, ping www.example.com would display the Fastly POP address 151.101.56.204.

Be sure to remove the Host entry from your hosts file after you make CNAME changes to point your domain to Fastly.

Deleting a domain

Follow the steps below to delete a domain from your service:

  1. On the Domains page, click the trash icon next to the domain you want to delete.
  2. Click the Confirm and delete button to confirm you want to delete your domain.
  3. Click the Activate button to deploy your configuration changes.
Back to Top