You can use Content Delivery Network (CDN) to accelerate the delivery of static resources from an Object Storage Service (OSS) bucket. This topic describes the scenario where CDN integrates with OSS and how to configure the acceleration in the CDN console.
- You have created a bucket in OSS and bound a custom domain name to the bucket. For more information, see Create a bucket and Bind custom domain names.
Alibaba Cloud CDN works with a precise scheduling system. The system redirects requests for static resources to the edge nodes closest to the end users who make the requests. This mechanism enables efficient retrieval of required resources, and minimizes network congestion.
- All requests to the origin server are sent to CDN nodes. This reduces the pressure on the origin server.
- Compared with the resources returned by the OSS bucket, the resources returned by CDN nodes incur a lower outbound data transfer fee.
- The client retrieves static resources from the closest CDN node. This minimizes the network transmission distance and ensures the quality of retrieved resources.
The following section describes how to add a Canonical Name (CNAME) record in the Alibaba Cloud Domain Name System (DNS) console.
- In the CDN console, use the custom domain associated with the OSS bucket to add a
- Log on to the CDN console.
- In the left-side navigation pane, click Domain Names.
- On the Domain Names page, click Add Domain Name.
- Select OSS Domain in the Origin Info section, and complete other required settings. The following table
describes the parameters for adding the CDN domain.
Parameter Option Description Domain Name to Accelerate N/AEnter a domain name, for example, ch.aliyun.com. Follow these rules:
- You can use a subdomain name or a wildcard domain name as the accelerated domain name,
- Wildcard domains are supported and Chinese domains are not supported. Follow the instructions
to enter a wildcard domain name, for example,
*.test.com. For more information about how to add a wildcard domain name, see Rules for adding wildcard domain names.
- You cannot add a domain name to Alibaba Cloud CDN more than once. If a DomainAlreadyExist error occurs, submit a ticket.
- Up to 50 domains can be added to Alibaba Cloud CDN under each account. To add more domains, submit a ticket.
- Content that is served from the domain must comply with the limits of Alibaba Cloud CDN. For more information, see Limits.
Business Type Image and Small File If you want to accelerate the delivery of small-sized static content on your website, such as small files, images, and style sheets, we recommend that you select Image and Small File from the Business Type drop-down list. Large File Download If you want to accelerate the delivery of static files that are larger than 20 MB, such as game installation packages, app updates, mobile read-only memory (ROM) upgrades, and app package downloads, we recommend that you select Large File Download from the Business Type drop-down list. VOD If you want to accelerate the delivery of on-demand video or audio content, we recommend that you select VOD from the Business Type drop-down list. DCDN If your website or application contains large amounts of dynamic content, you can select DCDN from the Business Type drop-down list. With simple configurations, Dynamic Route for CDN (DCDN) can accelerate the delivery of dynamic and static content separately. Static content is cached and dynamic content is retrieved from the origin based on the optimal link algorithm and protocol layer optimization of Alibaba Cloud.
After you select DCDN, you are prompted to go to the Dynamic Route for CDN console. You can then create and configure the accelerated domain. For more information.
Origin Info IP You can specify the public IP addresses of one or more servers. IP addresses of Alibaba Cloud Elastic Compute Service (ECS) instances are exempt from manual review. Site Domain You can specify the domain names of one or more publicly accessible origin servers.Note The domain name of the origin server cannot be the same as the accelerated domain name. Otherwise, a DNS resolution loop occurs, and the requests cannot be forwarded to the origin server correctly. For example, if you set the accelerated domain name to cdn.yourdomain.com, you can set the origin domain name to img.yourdomain.com. OSS Domain You can manually enter the Internet domain name of an Alibaba Cloud Object Storage Service (OSS) bucket, for example, xxx.oss-cn-hangzhou.aliyuncs.com. To view the Internet domain name of an OSS bucket, go to the OSS console. You can also directly select an OSS bucket under the same account. Function Compute Domain You must set the Region and Domain Name parameters of the Function Compute domain. For more information, see Set a Function Compute domain name. Port N/ASelect a port as needed.
- Port 80
Specifies access to resources over HTTP.
- Port 443
Specifies access to resources over HTTPS.
Region Outside Mainland China If you select Outside Mainland China, no Internet content provider (ICP) filing is required. Global If you select Global, you must apply for an ICP filing with the Ministry of Industry and Information Technology (MIIT) of China. For more information, see Domain filing. Mainland China If you select Mainland China, you must apply for an ICP filing with the MITT of China. For more information, see Domain filing.
- You can use a subdomain name or a wildcard domain name as the accelerated domain name, for example,
- Click Next.
After your CDN domain is reviewed and approved, you can view the domain name on the Domain Names page in the CDN console. The added domain is displayed in the Enabled state.
- Log on to the CDN console and obtain the CNAME of the CDN domain.
- In the left-side navigation pane, click Domain Names.
- On the Domain Names page, copy the CNAME domain of your accelerated domain.
- In the Alibaba Cloud DNS console, add a CNAME record.
- Log on to the Alibaba Cloud DNS console.
- On the Manage DNS page, click the Domains tab, select a domain, and then click Configure in the Actions column for the domain.
- Click Add Record to add a CNAME record.
- Type: Select
CNAMEfrom the drop-down list.
- Host: Enter the prefix of the accelerated domain.
Accelerated domain Host
- ISP Line: Use the default value.
- Value: Enter the CNAME domain that you have copied in step 1.
- TTL: Use the default value.
- Type: Select
- Click OK.
The CNAME record is added. Immediately after you add the record on Alibaba Cloud DNS, the CNAME record takes effect, and the CDN service is automatically enabled.Note
- If you modify the CNAME record, the record takes effect within 72 hours after the modification.
- After you add a CNAME record, it takes approximately 10 minutes to update the status in the console. The message "You must add the CNAME record" may still appear on the Domain Names page. Ignore this message.
- On a local computer, check whether the CNAME record works as expected.
- In the OSS console, turn on Auto CDN Cache Update for the CDN domain.
With Auto CDN Cache Update enabled, OSS refreshes an updated object on the corresponding CDN node immediately after the update is completed in the specified bucket. In this way, the CDN node can cache the latest object from OSS.
After you unbind the CDN domain from the specified bucket, OSS does not automatically refresh the objects cached on the CDN node. However, you can configure the refresh and preload features in the CDN console. For more information, see Configure the refresh and prefetch features.
- Log on to the OSS console.
- In the left-side navigation pane, select a target bucket under Buckets.
- You are navigated to the Overview tab. Click the Domain Names tab.
- On the Domain Names tab, turn on Auto CDN Cache Update for the CDN domain.
- To request OSS resources on a Web page, include the CDN domain followed by the target
file path in the request. For example, if the CDN domain is
mydomain.cnand the target file 123.jpg is located in the root directory, the URL for requesting the target file is
- To request OSS resources by using a client, specify the CDN domain as the OSS bucket domain, and use the CDN domain to connect to the bucket.