After an object is uploaded to an OSS bucket, a URL is automatically generated for the object. You can use this URL to access the object in the bucket. To access an uploaded object by using a custom domain name, you must attach the custom domain name to the bucket where the object is stored and add a CNAME record that directs to the Internet domain name of the bucket.
Notice In accordance with the requirements of the Regulations on the Administration of the Internet of the People's Republic of China, all users who need to attach custom domain names must file their domain names in advance to the Ministry of Industry and Communications. If your domain name is not on file, you can file it through the ICP service provided by Alibaba Cloud.

Concepts

The following describes key concepts about attaching a custom domain name to a bucket:
  • User domain name (also called custom domain name or self-hosted domain name): indicates the domain name that you buy from a domain name provider.
  • OSS domain name (also called bucket domain name): indicates the domain name that OSS assigns to your bucket. You can use this domain name to access the resources in your bucket. To access an OSS bucket by using your user domain name, you must attach the user domain name to the OSS domain name of the bucket, that is, add a CNAME record in the Domain Name System (DNS) of Alibaba Cloud.
  • Alibaba Cloud CDN domain name: indicates the CDN acceleration domain name that Alibaba Cloud Content Distribution Network (CDN) assigns to your user domain name. To use the CDN acceleration service to access the resources in your bucket, you must attach your user domain name to a CDN acceleration domain name, that is, add a CNAME record in the DNS of Alibaba Cloud.
  • Auto CDN cache update: If you modify an object in your bucket but the object cache on the CDN node does not expire, users can only access the object that is not modified. In this case, you must manually update the object cache on the CDN node. To simplify operations, OSS provides the auto CDN cache update function. After you enable this function, all modifications on the objects in your bucket are automatically updated to the CDN node. For more information, see Enable auto CDN cache update.

Application scenarios

For example, you have a website with the domain name img.abc.com, and the website contains a picture with the following URL: http://img.abc.com/logo.png. For easier management, you want to redirect all access requests for the picture to OSS without code modifying the code, that is, keep the URL of the picture unchanged. In this case, you can attach a custom domain name to your bucket. To do so, follow these steps:

  1. Create a bucket named abc-img, and upload the picture to the bucket.
  2. Attach the custom domain name img.abc.com to the bucket abc-img through the OSS console.
  3. After the custom domain name img.abc.com is attached to the bucket abc-img, OSS maps the domain name to the bucket.
  4. Add a CNAME rule on your DNS server to map the custom domain name img.abc.com to abc-img.oss-cn-hangzhou.aliyuncs.com (the OSS domain name of the bucket abc-img).
  5. After receiving a request for http://img.abc.com/logo.png , OSS redirects the request to the bucket abc-img based on the mapping relationship between img.abc.com and abc-img. That is, users who access the picture with the URL http://img.abc.com/logo.png are redirected to the following URL: http://abc-img.oss-cn-hangzhou.aliyuncs.com/logo.png.

The following table describes the access processes before and after you attach the custom domain name.

Before attaching the custom domain name After attaching the custom domain name
Access process
  1. A user sends a request to access http://img.abc.com/logo.png.
  2. DNS resolves the IP address of your server from the request.
  3. The user accesses the picture logo.png on your server.
  1. A user sends a request to access http://img.abc.com/logo.png.
  2. DNS resolves the URL abc-img.oss-cn-hangzhou.aliyuncs.com from the request.
  3. The user accesses the picture logo.png in the OSS bucket abc-img.

References