CDN: quick start
You can work with the SDN in the control panel.
- Create a CDN resource.
- Optional: connect a personalized domain.
- Check the operation of the CDN resource.
1. Create a CDN resource
A CDN resource is a set of settings that define how content will flow from the source to the CDN servers and be sent from the CDN servers to end users.
As a content source, you can specify:
- your source using the domain or IP address of the site;
- or baquet S3.
Your source.
S3
-
In the Control Panel, on the top menu, click Products and select CDN.
-
Click Create CDN resource.
-
Enter a name for the resource. The name has no effect on the resource settings and is used only for operation in the control panel.
-
In the Content Source field, select Own Source.
-
In the Domain or IP Address field, enter the IP address or domain of your site.
-
Click Create CDN Resource. When you create a CDN resource, a default domain is automatically generated. The files that will be distributed by the CDN server will be opened using a link of the form
*.selcdn.net.
You can leave the default domain or connect a personalized domain.
-
If you do not already have a bucket in S3 Selectel, create a public bucket and upload files to it using the S3: Quick Start instructions.
-
In the Control Panel, on the top menu, click Products and select CDN.
-
Click Create CDN resource.
-
Enter a name for the resource. The name has no effect on the resource settings and is used only for operation in the control panel.
-
In the Content Source block, select S3 Selectel.
-
Specify the address of a public bucket of the form
*.selstorage.ruwithout protocol. You can view the bucket address in the control panel: in the top menu, click Products → S3 → select project → Bucket section → bucket page → Domains tab → Main domain. -
Click Create CDN resource. When you create a CDN resource, a default domain will be automatically generated. Files that will be distributed by the CDN server will be opened using a link of the form
*.selcdn.net. You can leave the default domain or add a personal domain. -
Open the page of the created resource → Source tab.
-
In the Hostname block, in the Hostname field , when querying the source, specify the value you added in step 6.
2. Optional: add a personal domain to the resource
We recommend distributing content through a personal domain. The use of third-party domains can make it difficult to promote the site and affect the order in the search engine.
- Register a domain.
- Create a CNAME record in DNS hosting.
- Add a personalized domain in the control panel.
- Add an SSL certificate to the CDN resource.
- Replace the domain in the links on the site.
1. Register a domain
If you don't already have a domain that you want to use as a personal domain, register it. You can register a domain with Selectel.
If you already have a domain, go to the next step.
2. Create a CNAME record in DNS hosting
Only a subdomain for the main domain can be used as a personal domain, e.g. cdn.example.com for example.com. You cannot use the main domain as a personal domain.
-
Open the domain settings:
- if you have delegated a domain to Selectel, go to the Selectel control panel: in the top menu, click Products → DNS hosting → Domain zones section;
- if the domain is managed in another DNS hosting, open the control panel of this DNS hosting.
-
Create a resource record. Specify:
-
record type is CNAME;
-
record name is a subdomain of the form
cdn.example.com; -
value - default domain of the form
*.selcdn.net. Specify a domain without protocol, for examplecdn.example.com. Allowed length of each level of the domain - 63 characters. The 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 listed in the resource bar.
-
3. Add a personal 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 → Main tab.
-
In the Personal Domain block, click Add Personal Domain.
-
Specify the personal domain for which you configured the record.
-
Click Apply.
4. Add an SSL certificate to the resource
-
In the Control Panel, on the top menu, click Products and select CDN.
-
Go to Certificates for CDN resources.
-
If you want to issue a Let's Encrypt certificate:
3.1 On the menu, click Issue Let's Encrypt Certificate.
3.2 Select the CDN resource for which you want to issue a certificate.
3.3 Click Release.
-
If you want to download a personalized certificate:
4.1 From the menu, click Upload Personal Certificate.
4.2 Specify a name for the certificate. It will be used only in the control panel.
4.3 Add a certificate for the domain. It must start with
-----BEGIN CERTIFICATE-----and end with-----END CERTIFICATE-----.If you want to add multiple certificates, make sure that all certificates (the primary certificate for the domain, intermediate certificates, and the root certificate) create a complete chain. The
Issuervalue of the primary certificate must match theSubjectvalue of the first intermediate certificate, theIssuervalue of the first intermediate certificate must match theSubject ofthe second intermediate certificate, and so on.4.4 Add a 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.
-
Check the Distribute over HTTPS via CNAME checkbox.
-
In the Certificate field, select the certificate that you issued in step 3 or uploaded in step 4.
-
Click Apply. The resource will be in
PROCESSINGstatus while the settings are being applied . You cannot apply any other settings at this time. The settings will be applied when the share changes toACTIVEstatus.You can view certificate information in the control panel: in the top menu, click Products and select CDN → CDN resources → resource page → Certificates tab.
5. Replace the domain in the links on the website
If you selected your own content source when you created the resource in step 1, replace the domain in the URL of the static site files with the personal domain of the form cdn.example.com that you specified in step 3 when you created the CNAME record in step 2:
If the site is on a CMS, use a URL replacement plugin, if not, replace the URL in the site code.
3. Check the operation of the CDN resource
Your source.
S3
-
Wait until the CDN resource starts working - it will go to the
ACTIVEstatus. -
Open the file that the CDN should give you from the link on your site. Example link:
example.com/images/image.png. If the file does not open, check the site's operation. -
Open the file through the default domain using the link. Example link:
*.selcdn.net/images/image.png. If the file does not open, check the CDN resource and Host header settings. -
If you added a personal domain in step 2, open the file through the personal domain using the link. Example link:
cdn.example.com/images/image.png. If the file does not open, verify that the CNAME record you created in step 2 is correct.
-
Wait until the CDN resource starts working - it will go to the
ACTIVEstatus. -
Open the object directly through the repositories: in the control panel in the top menu, click Products → S3 → Bucket section → Bucket page. In the row of any object, click and follow the link in the Main Domain block . If the object does not open, there may be an access problem. For example, the bucket type has been changed to private or the object has been deleted.
-
Open the object through the default domain via a link. Example link:
*.selcdn.net/images/image.png. If the object does not open, try again after some time. If the error persists, clear the cache and verify that you made the specified settings when creating the CDN resource in step 1. -
If you added a personal domain in step 2, open the object through the CDN personal domain using the link. Example link:
cdn.example.com/images/image.png. If the file does not open, verify that the CNAME record you created in step 2 is correct.