tencent cloud

Cloud Object Storage

Setting Up Custom DNS

Download
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-07-03 10:53:12

Introduction

This document provides information on how to request COS services using a custom DNS.

Setting Up Dynamic Custom DNS Callbacks

This approach is more recommended because it is more flexible and provides greater control for the business layer.

Example Code

// Typically, configure this after initializing the key.
Cos.initCustomerDNSFetch(async (domain: string) => {
const dnsMap: Map<string, string[]> = new Map([
['service.cos.myqcloud.com', ["106.119.174.56", "106.119.174.57", "106.119.174.55"]],
['cos.ap-guangzhou.myqcloud.com', ["27.155.119.179", "27.155.119.180", "27.155.119.166", "27.155.119.181"]],
]);
let ips = null;
dnsMap.forEach((value, key) => {
// Using endsWith for filtering allows matching more subdomains. For example, 000000-1253960454.cos.ap-guangzhou.myqcloud.com can also be matched to cos.ap-guangzhou.myqcloud.com.
if (domain.endsWith(key)) {
console.log(`HOST: ${key}, IPS: ${JSON.stringify(value)}`);
ips = value;
}
});
return ips;
});

Setting Up Static Custom DNS Configuration

The following code demonstrates how to configure a static custom DNS.

Example Code

const dnsArray = [
{domain:'service.cos.myqcloud.com', ips: ["106.119.174.56", "106.119.174.57", "106.119.174.55"]},
{domain:'000000-1253960454.cos.ap-guangzhou.myqcloud.com', ips: ["27.155.119.179", "27.155.119.180", "27.155.119.166", "27.155.119.181"]},
{domain:'cos.ap-guangzhou.myqcloud.com', ips: ["27.155.119.179", "27.155.119.180", "27.155.119.166", "27.155.119.181"]},
];
// Typically, configure this after initializing the key.
Cos.initCustomerDNS(dnsArray);


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan