This topic introduces the principles and usage flow of the HTTPDNS custom resolution feature.
Introduction to the Custom Resolution Feature
In business scenarios, the custom resolution feature of HTTPDNS allows you to configure rules or use a Function Compute service to obtain tailored resolution results for a domain name.
Note: When using DoH, the resolved domain name does not support custom resolution.
Scenarios
Grayscale Testing: Consider the scenario where your domain name is
www.example.com
. In response to business expansion, you introduce a new service with the associated IP address1.1.X.X
. Prior to fully launching this service, you decide to perform a grayscale test targeting specific traffic, such as that from the APP version labeledTelecom_Shanghai
. For these select requests towww.example.com
, the domain name resolution process will return the IP address1.1.X.X
.Traffic rerouting: Suppose a car company's service domain name is
www.example.com
. They want the DNS resolution process to return the IP address of servers located in different regions based on specific business logic. For example, return different service IPs based on the car's permanent location. If a car's permanent location is in Guangzhou, the DNS query request initiated when accessingwww.example.com
returns the IP address of a server located in Guangzhou.
Rule Policy
Rule policy enables custom resolution through specific rules. By configuring various resolution parameters, you can more precisely direct user traffic from different carriers and regions to distinct service addresses.
The rule policy resolution flow is as follows:
In the HTTPDNS console, you can create a custom resolution rule policy for the domain name. Then, using the SDK or HTTP API on the client side, you can send a DNS query request with custom resolution parameters (How to add custom resolution parameters, ). The HTTPDNS server, upon receiving the request, will return a resolution result that aligns with your business requirements according to the established rules.
Usage Flow
Log on to the EMAS console or the .
Select Domain Name List and add a domain name for resolution.
From the left-side navigation pane, select custom resolution and click the Add Custom Resolution button.
In the pop-up drawer, select the newly added domain name and configure the corresponding line and rule, then click save.
The rule will be activated once you Enable it in the policy list.
For more information on adding a rule policy, see Add Rule Policy or .
Function Compute Policy
The Function Compute policy facilitates domain name access and traffic scheduling by integrating with Alibaba Cloud's Function Compute service, offering greater flexibility than rule-based policies. By embedding your business logic into the Function Compute service and configuring the appropriate Function Compute service within the resolution hook function, you can meet complex business needs.
The following is the principle diagram for Function Compute:
During the resolution lifecycle of the HTTPDNS server, hooks are provided at various stages to associate with the corresponding Function Compute service.
Before utilizing the Function Compute policy, you must acquire the necessary role permissions for Function Compute. The usage process is outlined below:
Usage Flow
Step 1: Configure Function Compute Service
Activate Function Compute and develop custom resolution functions. Once developed, publish your service and functions, and create a version or alias. For more information, see Create Function Compute Service .
Custom resolution functions are developed and tested in the Function Compute console. To ensure the safe operation of the HTTPDNS function compute policy, avoid selecting the default Latest version option when configuring the function compute policy. Instead, specify the officially released service and function version of Function Compute.
Step 2: Authorize Service-Linked Role
To allow HTTPDNS to use Function Compute for the custom resolution feature, authorize the service-linked role in the HTTPDNS console. For an introduction to the service role, see Authorize Service-Linked Role.
Step 3: Add Function Compute Policy for Domain Name
Each domain name requiring custom resolution must have a unique function compute policy. However, function compute policies for multiple custom resolution domain names may use the same Function Compute service.
For more information on adding a function compute policy, see Add Function Compute Policy .
Step 4: Enable Function Compute Policy
After adding and configuring the function compute policy, it is initially disabled. You can enable it from the corresponding list.
For details on how to enable the policy, see Enable Policy .