This topic walks you through how to use Alibaba Cloud Content Delivery Network (CDN) to accelerate the storage of Image and Small File in OSS.
Introduction
Common web portals mainly display static resources such as images, text, and videos. If your website resources are small images and files, set Business Type to Image and Small File. If your website has a large number of audio and video resources, select VOD. In this example, we use testcdn.top.
Benefits
Use the Alibaba Cloud ARMS monitoring tool to test the OSS resource URL and CDN accelerated domain name. The result is as follows:
The result of each test may be different due to network.
Based on the above data, it can be accelerated by about 35% by connecting to CDN.
Prerequisites
CDN is activated. For information about how to activate CDN, see Activate CDN.
An origin server that provides stable performance is deployed. If you do not have an origin server, follow the instructions in Create and manage an ECS instance in the console (express version) or Create a bucket to create one.
Add a domain name
Log on to the CDN console.
In the left-side navigation pane, click Domain Names.
On the Domain Names page, click Add Domain Name.
In the Add Domain Name dialog box, set the following items:
Region: Global (Excluding the Chinese Mainland)
Domain Name:
images.testcdn.top
Business Type: Image and Small File
Resource Group: Default Resource Group
ImportantThe first time you add a domain name to CDN, you must verify the its ownership. For more information, see Verify the ownership of a domain name.
Click Add Origin Sever. Set the following items:
Origin Info: OSS Domain
Domain Name: select your bucket domain name
Priority: Primary
Weight: 10
Port: 80
Read the Compliance Warranty Regarding Cross-border Data Transfers notice, select I have read and agree to the preceding compliance commitment. Click Next, and then click Back to Domain Management.
Add a CNAME record for a domain name
On the Domain Names page, find the domain name that you added and copy the value in the CNAME field.
Move the pointer over the left-side navigation pane of Alibaba Cloud to search for Products and Services. Enter DNS in the search box.
In the Enterprise Services & Cloud Communication section of the search results, click Alibaba Cloud DNS.
On the Authoritative DNS Resolution page, find the domain name that you want to manage and click DNS Settings in the
Actions
column.On the DNS Settings tab, click Add DNS Record. Set Type to CNAME, Host Record to
images
, Request Source to Default, Value to the CNAME that you copied in Step 1, and TTL 10 Minutes (recommend).
Troubleshooting
Issue
After you add an accelerated domain name and configure a CNAME record, you can directly access the acceleration resource 403.
Solution
This issue occurs because public read is not enabled for private OSS resources. For safety, the following operations are recommended.
On the CDN console, go to Domain Names page, find
images.testcdn.top
and click Manage.On the CDN Domain Names page, click Origin Fetch. Turn on Status for Alibaba Cloud OSS Private Bucket Access. Select Bucket in the Same Account.
Verify the access.