Custom Domain Name
While Scalingo provides a default public domain name for all applications, it’s generally a good idea to attach a custom domain name to an application, especially when in production.
Ideally, this custom domain name should allow users reach the application via a meaningful, easy-to-remember name (at least, compared to the default one provided by Scalingo).
By default, a maximum of 20 domain names can be attached to an application. Please get in touch with our Support team if you need more.
Buying a Domain Name
Domain names can be bought from registrars such as dnsimple, Gandi, or OVH Cloud. We do not sell domain names.
An exhaustive list of registrars can be found on the ICANN website.
The process is very similar from one registrar to the other: you have to first check the availability of the domain name you are interested in. If it is available, you can buy it for a limited amount of time, after which you will have to renew your subscription.
Setting Up the Domain Name
Once you own a domain name, the first step consists in making it point to your application. This step involves editing your domain name zone file. Steps may vary depending on your registrar, and differ depending on whether you want to setup a subdomain, an apex domain, or a wildcard domain.
Setting Up a Subdomain
The preferred way to make a subdomain point to your application consists in
creating a CNAME record in your zone file. This CNAME record must point
to the default domain name provided by Scalingo.
In the following example, the RR makes the www subdomain point to an
application named my-app, hosted in the osc-fr1 region (notice the
dot at the end of my-app.osc-fr1.scalingo.io.).
NAME TTL TYPE FIELD TARGET
www 10800 IN CNAME my-app.osc-fr1.scalingo.io.
Setting Up an Apex Domain
Apex domains are a bit specific, mostly because most
registrars don’t support creating CNAME DNS records for them.
-
If your registrar supports creating
CNAMEDNS records for apex domains, then you can follow the previous instructions to make it point to your application.
Cloudflare is known to supportCNAMErecord for apex domains.In such a case, the RR should look like this:
NAME TTL TYPE FIELD TARGET @ 10800 IN CNAME my-app.osc-fr1.scalingo.io. -
Some registrars support fields such as
ALIASorANAMEto provide the same functionality asCNAMErecords. If your registrar supports one of these, it’s the way to go. Follow the previous instructions, and make sure to replaceCNAMEby eitherALIASorANAME.
dnsimple, DNS Made Easy or PointDNS are known to support eitherALIASorANAMErecords for apex domains.In such a case, the RR should look like this:
NAME TTL TYPE FIELD TARGET @ 10800 IN ANAME my-app.osc-fr1.scalingo.io. -
If your registrar doesn’t support any of these, you have 3 options left:
- Fallback on using a subdomain and a
CNAMErecord for your application. - Migrate to another registrar.
-
Use
Arecords:A DNS
Arecord must point to an IPv4 address. At Scalingo, we don’t ensure that our ingress IP addresses won’t change over time.Creating
Arecords pointing to our ingress IP addresses is de facto a risk, so we don’t recommend doing so.If you still want to go that path, create an
ADNS record for each ingress IP address, depending on the region where your app is hosted.
- Fallback on using a subdomain and a
Setting Up a Wildcard Domain
To setup a wildcard domain, please create a CNAME record
in your zone file, as you’d do for a classic
subdomain.
In the following example, the RR makes any subdomain of the [apex
domain] point to an application named my-app, hosted in the osc-fr1 region:
NAME TTL TYPE FIELD TARGET
* 10800 IN CNAME my-app.osc-fr1.scalingo.io.
If you want Scalingo to manage the TLS certificate for the wildcard domain, make sure to follow these additional instructions.
Attaching the Domain Name
Once your domain name setup, it has to be added to the app hosted on Scalingo. This step is mandatory: it allows the platform to route requests targeting the domain name to the corresponding containers.
Using the Dashboard
- From your web browser, open your dashboard
- Click on the application for which you want to add a custom domain name
- Click on the Settings tab
- From the Setting sub-menu, select Public Routing
- Locate the Custom Domains block
- Click the Add a domain button
- In the popup window, fill the Name input
- Validate by clicking the Add button
Using the Command Line
- Make sure you have correctly setup the Scalingo command line tool
- Attach the domain name:
scalingo --app my-app domains-add <domain name>
Using the Terraform Provider
- Create a
scalingo_domainresource block in your Terraform file:resource "scalingo_domain" my-domain { common_name = "www.example.com" app = "${scalingo_app.my-app.id}" }In this example, we attach the domain name
www.example.comto the application.
Defining a Canonical Domain
If you have attached one or more custom domains to an application, you may want to redirect all requests to one of these, which becomes the canonical domain.
The redirection to the canonical domain is made using an HTTP 301 Moved
Permanently redirection.
Using the Dashboard
- From your web browser, open your dashboard
- Click on the application for which you want to add a custom domain name
- Click on the Settings tab
- From the Setting sub-menu, select Public Routing
- Locate the Custom Domains block
- Locate the domain name you want to set as canonical
- Click the star icon next to it to make it the canonical domain name
- In the popup window that appears, click the Apply button
Using the Command Line
- Make sure you have correctly setup the Scalingo command line tool
- Set the domain name you want as canonical:
scalingo --app my-app set-canonical-domain <domain_name>
Using the Terraform Provider
- Make sure the
canonicalattribute of the correspondingscalingo_domainresource block is set totrue:resource "scalingo_domain" "my-canonical-domain" { common_name = "www.example.com" app = "${scalingo_app.my-app.id}" canonical = true }In this example, we attach the domain name
www.example.comto the application and set it as canonical.