tencent cloud

Switch bucket to custom domain
Terakhir diperbarui:2025-06-04 18:23:37
Switch bucket to custom domain
Terakhir diperbarui: 2025-06-04 18:23:37

Background

To ensure overall service security and stability, for buckets created after January 1, 2024, if the default domain of Cloud Object Storage (COS) is used to access objects, preview of any type of file and download of apk/ipa type files are not supported. For details, see Implementation Notice on Security Management of COS Bucket Domain.

For buckets created after January 1, 2024, if you want to preview files directly or download apk/ipa type objects within the bucket through a browser, it is recommended to use a custom domain to access objects. Buckets created before January 1, 2024 are not affected by this change when the default domain is used for preview and download. However, for better service stability, it is recommended to prioritize using a custom domain.

This document describes how to configure a custom domain for a bucket, switching from accessing the bucket's default domain to accessing a custom domain.


Step 1: Registering and Filing a Domain

First, you need to prepare a custom domain that has been filed.
Domain registration: If you do not have a custom domain, you can purchase one at Domains.
Domain filing: If your custom domain is to be configured for a bucket in the Chinese mainland region, it must be filed.

Step 2: Configuring a Custom Domain for the Bucket

1. After preparing the custom domain, log in to the COS console, go to the bucket list, and select the bucket you need to configure.
2. Enter the bucket details page, and choose Domain Name and Transport Management > Custom Origin Server Domain.
3. Click Add Domain, and configure the domain information:
Domain: Enter the prepared custom domain.
Origin Server Type: The following types are available.
Default Origin Server: If you want to use the custom domain as the default origin server, select Default Origin Server.
Static Website Origin Server: If you want to use the custom domain for a static website, first enable the static website feature for the bucket, and then select Static Website Origin Server.
Global Acceleration Origin Server: If you want to use the custom domain for global acceleration, first enable the global acceleration feature for the bucket, and then select Global Acceleration Origin Server.
Note:
Addition, launch, or offline of domain name operations do not take effect immediately. The actual configuration takes some time and generally takes effect 30 minutes later. It is subject to the actual access status of your domain.
4. Configure an HTTPS certificate. If you want to access using the HTTPS protocol, you need to configure a certificate for the custom domain.
If you need to use your own certificate, paste the certificate content and private key content into the specified input boxes.
If you are using a certificate from Tencent Cloud, you can directly select an existing Tencent Cloud certificate under the current account in the pop-up window.
5. Upon completing the custom domain configuration, record the CNAME information (e.g., bucket-1250000000.cos.ap-beijing.myqcloud.com) for subsequent domain name resolution configuration.

Step 3: Configuring Domain Name Resolution

Go to the appropriate DNS service to configure the CNAME Resolution Record. Directions:
1. Add domain: Manually input the custom endpoint domain to be resolved, for example, www.example.com.
2. Add a record: Add a resolution record with record type CNAME for the custom endpoint domain. The record value is the default endpoint of the bucket pointed to by the CNAME, for example, bucket-1250000000.cos.ap-beijing.myqcloud.com.
3. Verify whether the resolution is successful: The resolution record takes some time to take effect. You can use the dig command or COS console to view whether the resolution is successful. Follow these steps for verification:
Enter the command dig mydomain.com in the command prompt to check whether the CNAME record has taken effect correctly. (Replace mydomain.com with your custom domain name during use.)
Log in to the COS console, view the custom domain name for bucket. If the CNAME of the domain name does not take effect successfully, a corresponding notification will appear.

Step 4: Accessing Your Custom Domain

After the above steps are completed, the configuration of the custom domain is finished. Below is an explanation of how to use the custom domain to access COS.

Viewing the Object Access Link

1. Log in to the COS console, find the bucket with the configured custom domain, and click to enter the File List. Select an object to enter the object details. For operation instructions, see Viewing Object Information.
2. Switch the designated domain to the custom origin server domain name. The object address and temporary link below will be correspondingly switched to the custom domain link. To access public read objects, you can use the object address (without signature). To access private read objects, you can use the temporary link (with signature).

Switching to the Custom Domain for API Access

For users who access COS directly via API, simply change the request Host to the custom domain when accessing.
GET /<0bjectKey> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com # Replace with the user's custom domain.
Date: GMT Date
Authorization: Auth String

Switching to the Custom Domain for SDK Access

For users using the SDK, simply set the domain parameter to the custom domain when initializing the client. Taking the Python SDK as an example, the code example is as follows.
domain = 'user-define.example.com' # User's custom domain
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token, Domain=domain, Scheme=scheme)
client = CosS3Client(config)
For code examples of switching to a custom domain in COS SDKs of various languages, refer to the following documentation:
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
Ya
Tidak

masukan