Connect CDN to object storage
This is an instruction to connect a CDN to an object storage container through a Selectel provider with content distribution through the personal domain.
- Create a public container in the object store.
- Create a CDN resource.
- Create a personalized domain for the CDN resource.
- Add a personal domain to a CDN resource.
- Check the CDN resource.
Create a public container
-
В control panels go to Object Storage → Containers.
-
Click Create a container.
-
Enter a name for the container. For compatibility with the S3 API, the container name must be unique within the object store and conform to Amazon S3's buckets naming rules, see the instructions for details Bucket naming rules Amazon documentation.
-
Select the container type to be public.
-
Select a storage class:
- standard storage — for storing and distributing frequently requested data;
- cold storage — for storing rarely requested data.
The storage class only affects resource cost The classes are technically and speed-wise the same. Once the container is created, the storage class cannot be changed.
-
If you need a container with Virtual-Hosted addressing to work with S3 API, in the block Addressing type select vHosted. You can enable Virtual-Hosted addressing only once.
-
Click Create a container.
-
Upload static content to the container that you want to distribute via CDN.
Create a CDN resource
- В control panels go to CDN → CDN resources.
- Click Create a 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.
- Select a Selectel provider.
- Select a content source Selectel Object Storage.
- Select project in which created a public container with content for the CDN.
- Select a container.
- Click Create a CDN resource.
Create a personal domain for the CDN resource
-
Open your DNS hosting control panel.
-
Create a third-level domain, e.g.
cdn.example.com
. This domain will be used as CDN personal domain for distributing content. -
Create a CNAME record:
- record type is CNAME;
- record name is a subdomain of the form
cdn.example.com
; - value — default domain in the format
*.selcdn.net
. You can view the domain in control panels under CDN → CDN resources → resource page → tab General. Specify the domain without the protocol.
Add a personal domain to a CDN resource
- В control panels go to CDN → CDN resources.
- Open the CDN resource page → tab General.
- In the block Personal domains click Add domain.
- Specify the third-level domain that you set up as a personal.
- Click Connect.
Check CDN resource
-
Make sure that at least 30 minutes have passed after all the settings — this time is necessary for the CDN resource to fully work.
-
Open the object directly through the repository, to do so in the control panels go to Object Storage → Containers and open the container page. In the row of any object, click on and follow the link on the block Main domain.
If the object does not open, there may be an access problem — for example, the container type has been changed to private or the object has been deleted.
-
Open the object through the default CDN domain using a link of the form
*.selcdn.net/images/image.png
. If the object does not open, check that the creating a CDN resource have made the specified settings. -
Open the object through a personal CDN domain using a link of the form
cdn.example.com/images/image.png
. If the object does not open, check if the CNAME record you added when you opened the object is correct creating a personalized domain.