After you upload an object to a bucket in OSS, a URL is generated for the object. You can use this URL to access the object in the bucket. To access an uploaded object through a custom domain name, you must bind the custom domain name to the bucket that contains the object and add a CNAME record that points to the public endpoint of the bucket.

Note You can bind up to 100 domain names to each bucket. A domain name can only be bound to a single bucket. Each account can have an unlimited number of domain names bound to buckets.

Implementation methods

Implementation method Description
Console A user-friendly and intuitive web application
OSS SDK for PHP SDK demos for various programming languages
OSS SDK for Node.js
OSS SDK for Browser.js
OSS SDK for Ruby

Common concepts

Before you bind a custom domain name to a bucket, you must understand the following concepts:
  • Custom domain name: the domain name that you purchase from a DNS service provider.
  • OSS endpoint or bucket endpoint: the domain name that OSS assigns to your bucket. You can use this domain name to access resources in your bucket. To access an OSS bucket through a custom domain name, you must bind the domain name to the OSS endpoint and add a CNAME record to Alibaba Cloud Domain Name System (DNS).
  • Accelerate endpoint: the transfer acceleration-based domain name that OSS assigns to your bucket after transfer acceleration is enabled. You can use accelerate endpoints to accelerate the access to resources in your bucket. Accelerate endpoints are especially suitable when you access data over long distance from different countries or continents. For more information about transfer acceleration, see Transfer acceleration.

Scenarios

For example, User A has a website with the img.abc.com domain name and the website contains an image with the http://img.abc.com/logo.png URL. To simplify management, User A wants to redirect all requests for the image to OSS without modifying the code or the image URL. In this case, User A can bind a custom domain name to the image object. The process is as follows.

  1. User A creates a bucket named abc-img in OSS and uploads the image to the bucket.
  2. User A binds the custom domain name img.abc.com to abc-img in the OSS console.
  3. After img.abc.com is bound to abc-img, OSS maps the custom domain name to the bucket.
  4. User A adds a CNAME rule on the DNS server to map img.abc.com to abc-img.oss-cn-hangzhou.aliyuncs.com, which is the OSS endpoint of abc-img.
  5. After receiving a request for http://img.abc.com/logo.png, OSS redirects the request to abc-img based on the mapping relationship between img.abc.com and abc-img. Users who attempt to access the image URL http://img.abc.com/logo.png are redirected to http://abc-img.oss-cn-hangzhou.aliyuncs.com/logo.png.

The following table compares how the object is accessed before and after the custom domain name is bound.

Before the custom domain name is bound After the custom domain name is bound
Access process
  1. An access request for http://img.abc.com/logo.png is sent.
  2. DNS resolves the request to the IP address of the source server.
  3. The source server returns the logo.png image to the requester.
  1. An access request for http://img.abc.com/logo.png is sent.
  2. DNS resolves the request to the OSS endpoint abc-img.oss-cn-hangzhou.aliyuncs.com.
  3. The OSS bucket abc-img returns the logo.png image to the requester.

References