Help Center/ Object Storage Service/ User Guide/ Domain Name Management/ Accessing a Bucket Using a User-Defined Domain Name
Updated on 2024-11-05 GMT+08:00

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.

Figure 1 Using a user-defined domain name to access objects in a bucket
  1. A user enters a file access address (that includes a user-defined domain name) in the browser to initiate an access request.
  2. DNS maps the user-defined domain name to the default domain name of the bucket.
  3. DNS translates the default domain name of the bucket to the IP address of the OBS server.
  4. OBS returns the IP address of the server to the client.
  5. The client sends a request with the user-defined domain name specified in the Host header to the IP address of the OBS server.
  6. 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).

Figure 2 Using the default domain name of a bucket to access objects in the bucket
  1. A user enters a file access address (that includes the default domain name of the bucket) in the browser to initiate an access request.
  2. DNS translates the default domain name of the bucket to the IP address of the OBS server.
  3. OBS returns the IP address of the server to the client.
  4. The client sends a request with the default domain name specified in the Host header to the IP address of the OBS server.
  5. 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

Table 1 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

  • User-defined domain names currently only allow requests over HTTP.

    If you want to use a user-defined domain name to access OBS over HTTPS, you need to configure CDN and manage HTTPS certificates on the CDN console.

    For details, see Configuring an HTTPS Certificate.

  • A user-defined domain name can be bound to only one bucket.
  • Chinese domain names are not supported.
  • The suffix of a user-defined domain name can contain 2 to 6 uppercase or lowercase letters.
  • 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.
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