Add a custom domain to a CDN resource
- Register a domain.
- Create a CNAME record in DNS hosting.
- Add a custom domain in the Control Panel.
- Add a TLS(SSL) certificate to the CDN resource.
- Replace the domain in links on the website.
1. Register a domain
If you do not yet have a domain that you want to use as a custom one, register it. You can register a domain in Selectel.
If you already have a domain, proceed to step 2.
2. Create a CNAME record in DNS hosting
You can only use a subdomain of your main domain as a custom domain, for example cdn.example.com for example.com. You cannot use the main domain as a custom domain.
-
Open the resource record editor for the domain:
- if you have delegated the domain to Selectel, go to the Selectel Control Panel: in the top menu, click Products → DNS Hosting → the Domain zones;
- if the domain is managed in another DNS hosting service, open the control panel for that DNS hosting service.
-
Create a resource record. Specify:
-
record type — CNAME;
-
record name — a subdomain such as
cdn.example.com; -
the value is a default domain in the form of
*.selcdn.net. Specify the domain without the protocol, for examplecdn.example.com. Each domain level can be up to 63 characters long. The total length of all levels must not exceed 253 characters.You can view the default domain in the control panel: in the top menu, click Products → CDN → CDN resources section → the domain will be specified in the resource line.
-
3. Add a custom domain in the Control Panel
-
In the control panel, on the top menu, click Products and select CDN.
-
In the CDN Resources section, open the resource page → General tab.
-
In the Custom Domain block, click Add Custom Domain.
-
Specify the custom domain for which you configured the record in step 2. If you have a Cyrillic domain, first convert it to Punycode. For example, for
сдн.пример.рфyou need to specifyxn--d1ask.xn--e1afmkfd.xn--p1ai. You can use any Punycode converter — for example, at sweb.ru. -
Click Apply. While settings are being applied, the resource will have the
PROCESSINGstatus. You cannot apply other settings at this time. The settings will be applied once the resource enters theACTIVE.
4. Add a TLS(SSL) certificate to the CDN resource
-
In the control panel, click Products in the top menu and select CDN.
-
Go to the CDN Resource Certificates section.
-
If you want to issue a Let's Encrypt certificate:
3.1. In the menu, select Issue Let's Encrypt certificate.
3.2. Select the CDN resource for which you want to issue a certificate.
3.3. Click Issue.
-
If you want to upload a custom certificate:
4.1. In the menu, select Upload custom certificate.
4.2. Specify a certificate name. It will only be used in the control panel.
4.3. Add the domain certificate. It must start with
-----BEGIN CERTIFICATE-----and end with-----END CERTIFICATE-----.You can add a certificate chain (main domain certificate, intermediate, and root) — make sure they form a complete chain. The
Issuervalue of the main certificate must match theSubjectvalue of the first intermediate certificate, theIssuervalue of the first intermediate certificate — with theSubjectvalue of the second intermediate, and so on.4.4. Add the private key. It must start with
-----BEGIN PRIVATE KEY-----and end with-----END PRIVATE KEY-----.4.5. Click Upload.
-
Go to the CDN Resources section.
-
Open the CDN resource page → Certificates tab.
-
Select the HTTPS delivery via CNAME checkbox.
-
In the Certificate field, select the certificate you issued in step 3 or uploaded in step 4.
-
Click Apply. While settings are being applied, the resource will be in
PROCESSINGstatus. You cannot apply other settings during this time. The settings will be applied once the resource switches toACTIVE.
5. Replace the domain in links on the website
If you chose your own content origin when creating a CDN resource, replace the domain in the URLs of your website's static files with the custom domain of the form cdn.example.com, which you specified in step 3 when creating a CNAME record in step 2:
If your website is on a CMS, use a plugin to replace the URLs; otherwise, replace the URLs in the website code.