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 by using 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.
- Custom domain name: the domain name that you purchase from a Domain Name System (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 by using a custom domain name, you must bind the domain name to the OSS endpoint and add a CNAME record to 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, see Transfer acceleration.
Scenarios and processes
For example, User A has a website by using the
img.example.com domain name and the website contains an image by using the
http://img.example.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. Process:
- User A creates a bucket named example-img in OSS and uploads the image to the bucket.
- User A binds the
img.example.comcustom domain name to the example-img bucket in the OSS console.
img.example.comis bound to example-img, OSS maps the custom domain name to the bucket.
- User A adds a CNAME rule on the DNS server to map
example-img.oss-cn-hangzhou.aliyuncs.com, which is the OSS endpoint of example-img.
- After OSS receives the
http://img.example.com/logo.pngrequest, OSS redirects the request to example-img based on the mapping relationship between
img.example.comand example-img. Users who attempt to access the image URL
http://img.example.com/logo.pngare redirected to
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|
|Console||A user-friendly and intuitive web application|
|PHP SDK||SDK demos for various programming languages|
- For more information about how to bind an accelerate endpoint, see Bind accelerate endpoints.
- For more information about how to access OSS resources from a static web page, see Configure static website hosting and Tutorial: Configure static website hosting by using a custom domain name.
- For more information about how to access OSS resources over HTTPS, see Host SSL certificates.