Accessing a Bucket Using a User-Defined Domain Name
After you upload a file to a bucket, OBS generates an access address for the file that includes the bucket's default domain name. Accessing this address using a browser will automatically download the file. To avoid exposing the default domain name of a bucket or to preview files online through a browser, you can bind a user-defined domain name to the bucket and use it to access the files in the bucket.
Scenarios
- File preview: To avoid automatic file downloads, you can bind a user-defined domain name to a bucket for online file preview.
- Preventing domain names from being blocked: Some application platforms may block the default domain name of a bucket. To access files in a bucket, you can bind a user-defined domain name to the bucket.
- Keeping the access address unchanged: To keep website or file access addresses unchanged after a migration or storage location change, you can upload the files to a bucket and bind a user-defined domain name to the bucket. This will establish a mapping between the website domain name and the default bucket domain name. In this way, you can still access the files using the original address.
- Improved brand image: Having a fixed and personalized domain name for accessing an enterprise website can make the enterprise appear more professional and reliable. This enhances enterprise image and improves customer experience.
- Easy access: You can use a user-defined domain name that is easy to remember to access a bucket and files in the bucket.
Principles
The following describes the process of accessing objects in a bucket using a user-defined domain name and the process of accessing objects in a bucket using the default bucket domain name.
Figure 1 shows the process of accessing objects in a bucket using a user-defined domain name.
- A user enters a file access address (that includes a user-defined domain name) in the browser to initiate an access request.
- DNS maps the user-defined domain name to the default domain name of the bucket.
- DNS translates the default domain name of the bucket to the IP address of the OBS server.
- OBS returns the IP address of the server to the client.
- The client sends a request with the user-defined domain name specified in the Host header to the IP address of the OBS server.
- OBS identifies the user-defined domain name in the Host header and returns a response with Content-Disposition set to inline to the client, which indicates that the file is expected to be displayed in the browser.
Figure 2 shows the process of accessing objects in a bucket using its default domain name (bucketName.obs.endpoint.myhuaweicloud.com).
- A user enters a file access address (that includes the default domain name of the bucket) in the browser to initiate an access request.
- DNS translates the default domain name of the bucket to the IP address of the OBS server.
- OBS returns the IP address of the server to the client.
- The client sends a request with the default domain name specified in the Host header to the IP address of the OBS server.
- OBS identifies the default domain name in the Host header and returns a response with Content-Disposition set to attachment to the client, which indicates that the file is expected to be downloaded and saved locally.
Constraints
Item |
Description |
---|---|
Bucket version |
Only buckets whose version is 3.0 or later support user-defined domain names. The bucket version can be viewed in the Basic Information area of the bucket's Overview page on OBS Console. |
Number of domain names |
By default, a bucket can have up to 20 user-defined domain names bound. |
Functions |
NOTE:
If an acceleration domain name is also required, to prevent objects in OBS buckets from being directly downloaded upon access, you need to perform other required operations after the user-defined domain name and the acceleration domain name have been configured. For details, see With CDN Acceleration Enabled, Why Are the Objects in My OBS Bucket Directly Downloaded When I Access Them? |
Prerequisites
- There is a bucket with objects. For details, see Creating a Bucket.
- There is a second-level domain.
- As required by the MIIT, if the bucket which a user-defined domain name is bound to is in a Chinese mainland region, you must complete the ICP filing.
Configuring a User-Defined Domain Name
You can use OBS Console, APIs, or SDKs to configure user-defined domain names.
Follow-Up Operations
FAQ
- How Do I Preview Objects in OBS in a Browser Online?
- Why Is the Message "NoSuchBucket" Displayed When I Use a User-Defined Domain Name to Access a Bucket That Can Be Accessed by the OBS Domain Name?
- Why Is the CNAME Resolution Status Unknown?
- Why Can Only the Domain Names I Bought on Huawei Cloud Be Automatically Resolved?
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot