You can read objects in OSS buckets by using the Alibaba Cloud CDN-based acceleration service. The acceleration service uses OSS buckets as origin sites and distributes the content from the origin sites to edge nodes. With its precise scheduling system, Alibaba Cloud CDN assigns requests to optimal edge nodes so that end users can quickly read their required content, easing Internet traffic congestion and improving response time.
To enable the Alibaba Cloud CDN-based acceleration service, you must direct your self-hosted domain name to a CDN acceleration domain name assigned by Alibaba Cloud CDN. Afterwards, all requests for your self-hosted domain name are redirected to the CDN edge nodes.
You can enable the Alibaba Cloud CDN-based acceleration service by the following two methods:
- Attach your self-hosted domain name to the domain name of an OSS bucket and enable the CDN-based acceleration service. For more information, see Method 1: Enable the CDN-based acceleration service through the OSS console.
- Direct the domain name of an OSS bucket to a CDN acceleration domain name, and then attach your self-hosted domain name to the CDN acceleration domain name (CNAME). For more information, see Method 2: Enable the CDN-based acceleration service through the CDN console.
Method 1: Enable the CDN-based acceleration service through the OSS console.
- Log on to the OSS console. In the left-side bucket list, click the name of the bucket to which you want to attach a custom domain name.
. In the Bind Self-Hosted Domain Name page, you can set the following parameters:
- Self-Hosted Domain Name: Enter the domain name that you want to attach, such as hello-world.com. The maximum length of a domain name is 63 characters.
- Enable Alibaba Cloud CDN: Enable the CDN-based accelerationservice.
- Add CNAME Record Automatically: The record of a CNAME managed by your Alibaba Cloud account can be automatically added. To add a record of a domain name that is not managed by your Alibaba Cloud account, you must manually configure the DNS of your DNS provider. For more information, see Manually add a CNAME record.
- Enter your self-hosted domain name, and enable Enable Alibaba Cloud CDN and Add CNAME Record Automatically.
- Click Submit.
Note If a domain name conflict message is prompted, the domain name is currently attached to a bucket owned by another user. To resolve this issue, click Obtain TXT and add a txt record of the domain name to the DNS of your DNS provider to verify the ownership of the domain name and forcibly attach the domain name to your bucket. However, if you forcibly attach a domain name to a new bucket, the domain name is detached from the bucket to which it is currently attached. For more information, see Verify domain name ownership.
- Updates to your domain name information take about one minutes to take effect. After updating a domain name, you can click Binding configuration to view CDN Domain Name and OSS Access Domain Name.
Method 2: Enable the CDN-based acceleration service through the CDN console.
- Log on to the Alibaba Cloud CDN console.
- Select .
- Enter the CDN acceleration domain name, and select the OSS bucket that you want to accelerate as the origin site.
Parameter Description Domain Enter your domain name, such as ch.aliyun.com. Resource Group Select the default resource group. Business Type Select the optimal business type for your scenario based on the content you have stored in OSS and how it is generally used. Origin Site Information Select the OSS domain name that you want to accelerate. Port Select the access port as needed. Acceleration Region Select the region in which you want to use the acceleration service.
- Click Next.
After you add a CDN acceleration domain name, a CNAME record is generated. You must add the CNAME record to the DNS of your DNS provider to enable the CDN-based acceleration service. For more information, see Manually add a CNAME record.
Manually add a CNAME record
The following steps apply only to scenarios where a CNAME record is not automatically added.
You must add a CNAME record to the DNS of your DNS provider. In this topic, Alibaba Cloud DNS is used as an example to describe the process of adding a CNAME record.
- Log on to the Alibaba Cloud CDN console and open the Domain Names page.
- Copy the CNAME of the domain name that you want to add.
- Log on to the Alibaba Cloud DNS console.
- In the domain name list, click Configure on the right of the domain name that you want to add a record.
- Click Add Record and enter the DNS information. The following table describes the parameters that you can configure.
Parameter Description Type Select the type of record to which the domain name directs.
In this example, select CNAME.
Host Enter the host record according to the prefix of the domain name. For example:
- If the domain name is www.aliyun.com, enter "www".
- If the domain name is aliyun.com, enter a character "@".
- If the domain name is abc.aliyun.com, enter "abc".
- If the domain name is a second-level domain name, such as a.aliyun.com or b.aliyun.com, enter an asterisk "*".
ISP Line Select the ISP line used to resolve the domain name.
We recommend that you select Default to allow the system to select the optimal line.
Value Enter the value of the record based on the selected record type.
In this example, enter the CNAME record that you copied in Step 2.
TTL Select the update period of the record. In this example, select the default value.
- Click OK.
Note An added CNAME record takes effect immediately. However, modifications to a CNAME record take up to 72 hours to take effect.
Check CNAME status
*.*kunlun*.com, the CNAME has taken effect.
Verify domain name ownership
- Click Obtain TXT to obtain a txt record generated by the system based on your information.
- Add the txt record to the DNS of your DNS provider. For a domain name added to Alibaba Cloud DNS, you can add a record in the Add Record page following the procedures described in Manually add a CNAME record. Then, you can configure the parameters as follows:
- Type: Select TXT.
- Host: Enter a character "@".
- Value: Enter the value generated on the Bind Self-Hosted Domain Name page in the OSS console.
- Retain default values for other parameters.
- On the Bind Self-Hosted Domain Name page, click I have added the TXT record，Continue submission.. If the system confirms that the information is correct, the verification is passed.
Enable auto CDN cache update
- Log on to the OSS console.
- In the left-side bucket list, click the name of the bucket that you want to enable the auto CDN cache update function.
- Click the Domain Names tab.
- Enable Auto CDN Cache Update for the record that a self-hosted domain name is attached.
After attaching a self-hosted domain name to a bucket, you can access a target OSS resource using the URL that is composed of your self-hosted domain name and the path of the resource, such as
http://mydomain.cn/test/1.jpg. However, if you access OSS only with your self-hosted domain name (such as
http://mydomain.cn) an AccessDenied error occurs because the default page of the OSS static website is not configured. For more information about configuring the default page of an OSS static website, see Host a static website.