This topic describes how to map a custom domain name to a bucket.

Object Storage Service (OSS) allows you to map a custom domain name to an OSS bucket based on a CNAME record. You can use this method to migrate data to OSS. For example, you have the domain name, and all of your images can be accessed by using URLs in the following format: To access your images by using original URLs after you migrate the images to an OSS bucket, perform the following steps:

  1. Activate OSS and create a bucket.
  2. Map to the created bucket.
  3. Upload an image to the OSS bucket.
  4. Modify the Domain Name System (DNS) configurations of the domain name. Add a CNAME record to map to an OSS endpoint such as

You can use the original URL to access the image that is stored in the OSS bucket. For more information about how to map custom domain names, see Map custom domain names.

To use your custom domain name as the endpoint of a bucket when you use OSS SDK for Ruby, set the value of :cname to true. Example:

require 'aliyun/oss'

include Aliyun::OSS

client =
  endpoint: 'ENDPOINT',
  access_key_id: 'ACCESS_KEY_ID',
  access_key_secret: 'ACCESS_KEY_SECRET',
  cname: true)

bucket = client.get_bucket('my-bucket')

Note If a custom domain name is mapped to a bucket, the domain name cannot be used to call the list_buckets operation.