After you upload objects to buckets, Object Storage Service (OSS) automatically generates URLs for the objects. You can use the URLs to access the objects. If you want to access the objects by using custom domain names, you must map the custom domain names to the buckets in which the objects are stored and add CNAME records for the custom domain names.
Prerequisites
- A custom domain name is registered. For more information, see Register a generic domain name.
- The Internet Content Provider (ICP) filing is complete for the domain name that you
want to map to your bucket in the Chinese mainland.
For more information about how to apply for an ICP filing, see What is an ICP filing?
Limits
- Custom domain names cannot contain Chinese characters.
- OSS does not impose limits on the number of domain names that can be mapped to the buckets per account.
- Each domain name can be mapped to only one bucket, and each bucket can be mapped to up to 100 domain names.
- If you map a custom domain name to a bucket in the OSS console, the domain name cannot contain wildcard characters. If Alibaba Cloud CDN is enabled to accelerate the retrieval of resources from an OSS bucket, you can map a custom domain name that contains wildcard characters to the bucket. However, the domain name does not appear in the OSS console.
Usage notes
You can map a custom domain name to a bucket to meet the requirements in the following scenarios:
- To make sure that the image objects in a bucket that is created in a region in the Chinese mainland after September 23, 2019 are previewed but not downloaded when you access the objects by using a browser.
- To make sure that the web pages of a static website that is hosted in an OSS bucket are accessed but not downloaded.
Rules for using custom domain names
www.example.com
is mapped to the bucket. The URLs that are used to access the object are different
before and after the custom domain name is mapped to the bucket.
- Before the custom domain name is mapped to the bucket
You can use the following URL that contains the default domain name of the bucket to access the exampleobject.jpg object:
https://examplebucket.oss-cn-hangzhou.aliyuncs.com/exampleobject.jpg
. - After the custom domain name is mapped to the bucket
You can use the following URL that contains the custom domain name mapped to the bucket to access the exampleobject.jpg object:
https://www.example.com/exampleobject.jpg
.Note After you map a custom domain name to a bucket, you can preview an image object in the bucket when you access the image object. If the object cannot be previewed but can be downloaded as an attachment, the browser may not support the preview of images in specific formats. To resolve this issue, you must install a plug-in that allows you to preview images in specific formats in a browser.
Use the OSS console
Check whether the CNAME record takes effect
You can run the ping or lookup command to check whether a specified CNAME is in effect. If the request is redirected
to *.oss-cn-*.aliyuncs.com
, the CNAME is in effect.
Verify the ownership of a domain name
If the custom domain name that you want to map to a bucket is not managed by your Alibaba Cloud account or is registered with another vendor, you must verify the ownership of the domain name before you can map the domain name to the bucket.
Remove a domain name mapping
If you no longer need to use a custom domain name, you can remove the mapping between the custom domain name and the bucket.
- On the Buckets page, click the name of the bucket to which the custom domain is mapped. In the navigation tree, choose .
- On the Domain Names page, find the custom domain name and click Manage Mapping Configurations in the Actions column.
- In the Manage Mapping Configurations panel, click Unbind. Then, click OK.
References
- If you want to improve upload and download performance, you can map an accelerate endpoint to the bucket. For more information, see Map an acceleration endpoint.
- If you want to access resources in OSS buckets by visiting a static website, configure static website hosting for the buckets. For more information, see Configure static website hosting and Use a custom domain name to configure static website hosting.
- If you want to use HTTPS to access a custom domain name, you must upload your SSL certificate in the OSS console. For more information, see Host SSL certificates.