staging-abc123-yourproject.eu.platformsh.site. This is true even if you’ve already added a custom
domain to your production environment; preview environments don’t automatically inherit it.
If you want preview environments accessible at meaningful, predictable URLs, you can add a custom
domain to each one — but you must have at least one custom domain set up on your production
environment first. You then follow the same basic steps as setting up a production
custom domain — configure DNS, then add the domain to the environment
— with two differences:
- You don’t need to update your routes configuration
- You must attach the preview domain to its corresponding production domain — that is, tell Upsun which production domain’s routing rules the preview domain should follow.
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.Before you start
You need:- A production environment with at least one custom domain configured
- At least one preview (staging or development) environment
- Optional: The Upsun CLI (v4.8.0+)
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
-
Get the CNAME value for your preview environment — this is the Upsun-provided hostname your DNS record needs to point to:
-
Configure your DNS provider.
In particular, make sure your DNS record points to the target of your preview environment.
Use your preview environment’s CNAME value rather than your production environment’s. Upsun recommends this to ensure correct routing for your preview environment.
-
Run a command similar to the following:
Preview domains cannot be edited
To change a preview environment’s custom domain, delete it and add a new one.Example
You’ve added theexample.com custom domain to your production environment.
You now want to add the staging.example.com custom domain to a preview environment called staging.
To do so, follow these steps:
- Using the CLI
- In the Console
Run the following command:
staging environment needs to exist
for you to add the staging.example.com custom domain successfully.
If the staging environment is later removed,
the staging.example.com custom domain is removed too.
Manage custom domains on a preview environment
- Using the CLI
- In the Console
| Action | Command |
|---|---|
| List all domains | upsun domain:list --environment <ENVIRONMENT_NAME> |
| View a specific domain | upsun domain:get <YOUR_PREVIEW_DOMAIN> --environment <ENVIRONMENT_NAME> |
| Remove a domain | upsun domain:delete <YOUR_PREVIEW_DOMAIN> --environment <ENVIRONMENT_NAME> |