Connect CDN to S3
These are instructions for connecting a CDN to an S3 bucket with content distribution via a personal domain.
- Create a public bucket in S3.
- Create a CDN resource.
- Create a personalized domain for the CDN resource.
- Add a personalized domain to the CDN resource.
- Check the CDN resource.
1. Create a public bucket
-
In the control panel, on the top menu, click Products and select S3.
-
Click Create Bucket.
-
Enter the name of the bucket.For compatibility with the S3 API, the bucket name must be unique within S3 and follow Amazon S3 bucket naming rules, see the Bucket naming rules instructions in the Amazon documentation for details.
-
Select the type of buckets — public.
-
Select a storage class:
- standard storage — for storing and distributing frequently requested data;
- cold storage — for storing rarely requested data.
Storage class only affects the cost of resources, technically and in terms of speed the classes are the same.After creating a bucket, the storage class cannot be changed.
-
If you need a bucket with Virtual-Hosted addressing to work with S3 API, in the Addressing Type block, select vHosted.You can enable Virtual-Hosted addressing only once.
-
Click Create Bucket.
-
Upload static content to the bucket that you want to distribute via CDN.
2. Create a CDN resource
- In the Control Panel, on the top menu, click Products and select CDN.
- Click Create CDN resource.
- Enter the name of the resource.The name does not affect the resource settings and is used only for operation in the control panel.
- In the Content Source block, select S3 Selectel.
- Select the project in which you created a public bucket with content for the CDN.
- Pick a bucket.
- Click Create CDN resource.
3. Create a personal domain for the CDN resource
-
Open your DNS hosting control panel.
-
Create a third-level domain, such as
cdn.example.com.
This domain will be used as your personal CDN domain for content distribution. -
Create a CNAME record.To do so, 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 a protocol.You can view the default domain in the control panel: in the top menu, click Products → CDN → CDN Resources → CDN Resources → Resource page → General tab.
4. Add a personal domain to a CDN resource
- In the Control Panel, on the top menu, click Products and select CDN.
- Open the CDN resource page → General tab.
- In the Personal Domains block, click Add Domain.
- Specify the third-level domain you created as your personal domain.
- Click Connect.
5. Check CDN resource
-
Wait for the CDN resource to work.Usually it takes at least 30 minutes after all settings have been made.
-
Open the object directly through the repository, to do this in the control panel in the top menu click Products → S3 → Buckets section → buckets page.In the row of any object click on 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 CDN domain using a link like
*.selcdn.net/images/image.png
.If the object does not open, try again after a while.If the error persists , clear the cache and verify that you made the specified settings when creating the CDN resource. -
Open the object through the CDN personal domain using a link like
cdn.example.com/images/image.png
.If the object does not open, verify that the CNAME record you added when you created the personal domain is correct.