Help Center/ Object Storage Service/ User Guide/ Domain Name Management/ Accessing a Bucket Using a User-Defined Domain Name
Updated on 2026-11-02 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.
  • 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.

How It Works

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 how to use a user-defined domain name to access objects in a bucket.

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 a 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 how to use the bucket's default domain name (bucketName.obs.regionIDmyhuaweicloud.com) to access objects in the bucket.

Figure 2 Using the bucket's default domain name 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. To check the version of a bucket, go to OBS Console, click the bucket name and go to the Overview page, and find the version in the Basic Information area.

Number of domain names

By default, a bucket can have up to 20 user-defined domain names bound.

Functions

  • 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 63 uppercase or lowercase letters.
  • Per MIIT regulations, if your bucket with a user-defined domain name is located in a Chinese mainland region, you must complete an ICP filing in advance.
  • User-defined domain names are typically used for public access to OBS buckets. For intranet access, it is recommended to use the bucket's default domain name (bucketName.obs.regionID.myhuaweicloud.com).
NOTE:

If an acceleration domain name is used, to prevent objects in OBS buckets from being forcibly downloaded when accessed, configure the user-defined domain name and the acceleration domain name, and then perform the required operations described in Why Are Objects Forced to Download When CDN Acceleration Is Enabled?

Permissions

In cross-account scenarios, the APIs for setting, obtaining, or deleting a bucket's user-defined domain name cannot be called. Assume there are two Huawei Cloud accounts. One account cannot configure, obtain, or delete the other's user-defined domain name.

In the same account, you must be the bucket owner or have the permissions to set (obs:bucket:PutBucketCustomDomainConfiguration), obtain (obs:bucket:GetBucketCustomDomainConfiguration), and delete (obs:bucket:DeleteBucketCustomDomainConfiguration) the user-defined domain name. You are advised to use IAM or bucket policies for authorization. For more information about OBS authorization methods, see Differences Between OBS Permissions Control Methods.

Prerequisites

  • There is a bucket with objects. For details, see Creating a Bucket.
  • There is a second-level domain.
  • Per MIIT regulations, if your bucket with a user-defined domain name is located in a Chinese mainland region, you must complete an ICP filing in advance.

Configuring a User-Defined Domain Name

You can configure user-defined domain names using OBS Console, APIs, obsutil, or SDKs, but not using OBS Browser+.

Specifically, perform the following steps:

  1. Bind a user-defined domain name to the bucket.
  2. Add a CNAME record set to map the user-defined domain name to the default domain name of the bucket.
  3. (Optional) Configure HTTPS to secure access through the user-defined domain name.

Using a User-Defined Domain Name to Access Objects

After a user-defined domain name is bound to a bucket and the domain name resolution is successful, verify that you can use the domain name to access objects. You can access objects through a user-defined domain name using APIs, SDKs, or obsutil, but not using OBS Console or OBS Browser+.

Application Practices

Best Practices

  • Secure Transmission: Configuring HTTPS

    Configure an SSL certificate for a user-defined domain name and enforce HTTPS access. HTTPS provides end-to-end data encryption between the client and server using TLS/SSL. It also verifies server identity via certificates to ensure data confidentiality, integrity, and authenticity. The SSL certificate for a bucket's default domain name is centrally managed by Huawei Cloud and requires no additional configuration. However, you must configure a separate certificate for a user-defined domain name or CDN acceleration domain name. You are advised to prepare a backup certificate and configure an HTTP fallback policy in advance to prevent service interruptions caused by certificate expiration.

    For details about how to configure HTTPS, see Certificate Hosting.

  • Cross-Origin Access: Configuring CORS Rules

    When a frontend application needs to access OBS resources across origins (with different protocols, domains, or ports), you must configure CORS rules to allow cross-origin requests from specified domains. You are advised to configure specific Allowed Origin instead of using the wildcard (*), to follow the principle of least privilege to narrow down Allowed Method, and to explicitly list the necessary Exposed Header. In scenarios with high security requirements, the wildcard (*) is strictly prohibited. In scenarios with high performance requirements, you can configure a longer cache duration to reduce preflight requests.

    For details about how to configure CORS rules, see Configuring CORS to Allow Cross-Origin Access to OBS.

  • Domain Switching: Migrating Without Service Interruption

    When switching traffic from a bucket's default domain name to a bound user-defined domain name or CDN acceleration domain name, use a phased switching strategy to avoid service interruptions:

    1. Preparation phase: Bind a user-defined domain name or CDN acceleration domain name to your bucket, add a CNAME record set, and verify functionality and performance in a test environment.
    2. Gray release phase: During off-peak hours, route a fraction of your business traffic to the user-defined domain name, then gradually complete the full traffic migration.
    3. Verification phase: Check monitoring metrics and access logs to verify that the service is operating normally.
    4. Full release phase: Route all business traffic to the user-defined domain name to finalize domain migration.
    5. Rollback plan: If any issues arise during full release, immediately roll back traffic to the bucket's default domain name, analyze the root cause, resolve the issue, and retry the domain switching.
  • Performance and Security: Isolating Business Functions with Subdomains

    You can assign different subdomains to business functions, for example, txt.example.com for text resources, image.example.com for image resources, and video.example.com for video resources. Routing client requests to specific subdomains achieves domain isolation. This approach improves browser concurrency performance and allows you to configure independent caching policies and fine-grained access controls for each subdomain.

  • Feature Extension: Configuring Static Website Hosting

    Upload your static website files (including HTML, CSS, and JavaScript files) to a bucket and grant anonymous users read permissions for these files. Next, configure static website hosting for the bucket and specify the default homepage and 404 error page. Finally, configure a user-defined domain name for the bucket. This allows the static files in the bucket to be published as a website that is publicly accessible through your user-defined domain name.

    Static website hosting is not supported through the bucket's default domain name. You must access the hosted website using a user-defined domain name.

    For details about how to configure static website hosting, see Static Website Hosting.

  • Access Latency: Accessing User-Defined Domain Names Involves Additional DNS Resolution

    When you access a bucket through a user-defined domain name, DNS resolution requires two steps: first, resolving the user-defined domain name to the OBS domain name, and second, resolving the OBS domain name to the IP address of the OBS server. In contrast, accessing a bucket directly through its default domain name requires only a single resolution step to map the default domain name to the OBS server IP address. As a result, initial request latency may be slightly higher when accessing an OBS bucket through a user-defined domain name rather than directly using the default domain name. This delay is standard behavior of the DNS resolution mechanism, not an issue with OBS. To optimize access speed, you can configure a CDN acceleration domain name.

  • Access Acceleration: Configuring a CDN Acceleration Domain Name

    If you need to distribute static resources to users around the world, we recommend configuring a CDN acceleration domain name for your bucket. By caching content on globally distributed CDN edge PoPs, you can reduce access latency and enhance user experience.

    Choose a CDN service type (website acceleration, file download acceleration, or VOD acceleration) based on your specific workload to achieve optimal acceleration. When configuring acceleration, specify the service area (Chinese mainland, outside the Chinese mainland, or global) and the bucket type (public or private). For private buckets, the system automatically creates a CDNAccessPrivateOBS agency to authenticate requests and allow CDN to retrieve data from the bucket.

    For details about how to configure a CDN acceleration domain name, see Accessing a Bucket Using a CDN Acceleration Domain Name.

  • Business Continuity: Maintaining Access URLs After Data Replication

    If you need to migrate data without changing the access domain name, you can first replicate data from one bucket (for example, bucket A) to another bucket (for example, bucket B) using data replication (supporting same-account, cross-region replication, cross-account, cross-region replication, same-account, same-region replication, and cross-account, same-region replication). Then, unbind the user-defined domain from bucket A and bind it to bucket B. This ensures that even after data is migrated to a new bucket, the user access URLs remain unchanged.

    For details about data replication, see Data Replication Overview.

Security Protection

  • Data Theft Prevention: Configuring URL Validation

    Some unauthorized websites link directly to images, videos, and other assets hosted on other sites to expand their own content at no extra cost. This increases the load on origin servers while driving up bandwidth consumption and traffic costs. To prevent this, OBS supports URL validation using referer whitelists and blacklists. Whitelists allow access from trusted sources, while blacklists block malicious ones.

    Note that requests may bypass URL validation rules if they hit a CDN cache. Therefore, if you have configured a CDN acceleration domain for your bucket, you must set up corresponding URL validation rules on the CDN side as well.

    For details about how to configure URL validation, see Configuring URL Validation to Prevent Unauthorized Access to Your Data.

  • Fault Analysis and Troubleshooting: Configuring Bucket Log Storage and Auditing

    Enable OBS bucket log storage to automatically record access details, format log files according to fixed naming rules, and upload them to a specified log storage bucket. Bucket logs capture all request details, including access timestamps, source IP addresses, request types, operation types, and response statuses, helping you perform security auditing, performance analysis, and troubleshooting. For details, see Bucket Logging Overview.

    Cloud Trace Service (CTS) is a dedicated audit logging service in Huawei Cloud security solutions. It tracks and records operations performed on your cloud resources, including user identities, IP addresses, operation details, and response statuses. These operation records enable efficient security auditing, issue tracking, and resource tracing. For details, see Using CTS to Audit OBS Operations.

References