By default and for each preview environment, Upsun automatically replaces the custom production domain with an automatically generated URL. If you don’t want to use these default URLs, you can add a custom domain to each of your preview environments (
staging or development environment types).
To do so, no need to modify your routes configuration.
When you add a new custom domain for a preview environment,
just attach it to the custom production domain it replaces.
If you have multiple custom production domains,
you need to select which one you’re replacing.
Example
You have two environments, a production environment and a staging environment. You’ve added theexample.com custom domain to your production environment.You want to add the staging.example.com custom domain to your staging environment.
To do so, you need to attach the new staging.example.com custom domain
to its corresponding custom production domain example.com.You can then access your staging environment through staging.example.com,
and still access your production environment through example.com.- The custom production domains in your existing routes configuration
- The custom domains for preview environments attached to each of those custom production domains
Before you start
You need:- A production environment with at least one custom domain already set up
- At least one preview (staging or development) environment
- Optional: The Upsun CLI (v4.8.0+)
If you delete a custom production domain,
all of the attached custom domains for preview environments are deleted too.
You need to rebuild the affected preview environments for the deletion to be complete.
Add a custom domain to a preview environment
To add a custom domain to a preview environment, follow these steps:- Using the CLI
- In the Console
-
To get the target for your preview environment,
run the following command:
-
Configure your DNS provider.
In particular, make sure your DNS record points to the target of your preview environment.
Using the target of your production environment to configure your DNS provider is technically possible, but Upsun recommends using the target of your preview environment as a best practice.
-
Run a command similar to the following:
You can’t update a custom domain when it’s used on a preview environment.
You can only delete it and create a new one as a replacement.
Example
You’ve added themysite.com custom domain to your production environment.
You now want to add the mydev.com custom domain to a preview environment called Dev.
To do so, follow these steps:
- Using the CLI
- In the Console
Run the following command:
Dev environment needs to exist
for you to add the mydev.com custom domain successfully.
If the Dev environment is later removed,
the mydev.com custom domain is removed too.
List the custom domains of a preview environment
- Using the CLI
- In the Console
Run a command similar to the following:
Get a specific custom domain used on a preview environment
- Using the CLI
- In the Console
Run a command similar to the following:
Remove a custom domain from a preview environment
- Using the CLI
- In the Console
Run a command similar to the following: