Domain Mappings allow you to customize how traffic is routed between Domains and Origins.
If you have a single Domain and a single Origin, your routing configuration is straightforward. However, if your service contains multiple Domains and Origins, you need to define how requests for each Domain should be routed—that is, which Origin should receive the request after it passes through the CDN.
A Domain Mapping is defined by:
- Domain name
- Path pattern
- Origin
Example #
For example, assume you have the following configuration:
- Domain Mapping 1
- Domain –
www.example.com - Path pattern –
/blogs/*Origin –my-blogs-bucket.s3-us-west-2.amazonaws.com
- Domain –
- Domain Mapping 2
- Domain –
www.example.com - Path pattern –
/images/* - Origin –
my-images-bucket.s3-us-west-2.amazonaws.com
- Domain –
With this configuration, requests are routed as follows:
https://www.example.com/blog/myblog.html → my-blogs-bucket.s3-us-west-2.amazonaws.com
https://www.example.com/images/mydog.jpg → my-images-bucket.s3-us-west-2.amazonaws.com
Adding a New Domain #
When you first add a Domain, you specify its initial mapping.
You can use /* as the path pattern to route the entire Domain to a specific Origin. After the Domain has been created, you can add additional mappings as described below.
Adding a Domain Mapping #
Adding an additional Domain Mapping is similar to adding a Domain. Specify the name of the existing Domain in the Domain field, then define the additional path pattern and the Origin to which you want to route traffic.
To add a Domain Mapping:
- Navigate to your service.
- In the sidebar, select Domains.
- Click the Create Domain Mapping button.
- Complete the new Domain Mapping form:
- Domain – Enter the name of the existing Domain.
- Path – Specify the path that should be mapped to the destination Origin. Use
/*to route the entire Domain to an Origin. - Destination – Select an Origin from the list of Origins configured for your service. See this page for details on adding an Origin.
Once created, the new mapping will appear in the table next to the Domain name.
Adding a Path Mapping #
If you only want to add an additional path to the same Domain and Origin, you can do so through Adding a Domain Mapping.
However, there is a simpler option that allows you to add the path directly without specifying the Domain and Origin again.
To add a Path Mapping:
- Navigate to your service.
- In the sidebar, select Domains.
- Locate the existing Domain and Origin mapping and click Add New Path.
- Enter the new path.
- Click Save.
Once created, the new Path Mapping will appear in the table within the row corresponding to the existing Domain and Origin.
Updating a Mapping #
For an existing mapping, you can only update its path.
If you need to change the Domain or Origin, you must create a new mapping and delete the existing one.
To update a Path Mapping:
- Navigate to your service.
- In the sidebar, select Domains.
- Locate the existing mapping path. Hover over the path until the Edit icon appears, then click it.
- Enter the new path.
- Click Save.
Once updated, the new path will appear in the table.
Deleting a Mapping #
You can delete individual Path Mappings. Once all paths associated with a specific Domain and Origin have been removed, the entire mapping is also deleted.
To delete a Path Mapping:
- Navigate to your service.
- In the sidebar, select Domains.
- Locate the existing mapping path. Hover over the path until the Delete icon appears, then click it.
Deleting a Domain #
To delete an entire Domain from your service configuration, you must remove all mappings associated with that Domain.
Once all associated mappings have been removed, the Domain is automatically deleted and removed from the service’s list of Domains.