HTTPDNS
HTTPDNS provides domain name resolve services over the HTTP interface, with features such as domain name anti-hijacking, precise scheduling, and real-time resolution.
Enable HTTPDNS
Enable DNS in the
global configuration
/DNS
page:Add a partition port in the
Global Configuration
/Configure Partition Port
page and selecthttpdns
as the type:Adding an
HTTP/HTTPS
application to theApplication
page:Add
upstream
to the application, select the loopback address of the node upstream, and enter thehttpdns
partition port from thehttpdns
port added in the step above:Adding
Page Rules
to the application:- Set the HTTP header so that httpdns gets the client IP correctly.
Select
Action
, add actionSet Proxy Header
, fill inX-Real-IP
in the header, and set the value toBuilt-In Variable
-Client Address
. - Select
Proxy
, upstream select the upstream added in the previous step.
- Set the HTTP header so that httpdns gets the client IP correctly.
Select
At this point, the HTTPDNS configuration is complete, add DNS applications and records to DNS
and you can use HTTPDNS for queries.
HTTPDNS Query
Request URL:http://{your app}/?host={your domain}&query=4,6&ip={client ip}
Request method:GET
Request parameters:
Name | Required | Description |
---|---|---|
host | yes | the domain name to resolve. |
ip | no | Source IP of customer, If this parameter is not specified, the source IP of the requested connection is used by default. |
query | no | Specifies the type of the resulting IP, either 6(IPv6) or 4(IPv4). The default is 4. |
type | No | Specifies the format of the query result, currently only “json” is supported. |
Response:
Name | Description |
---|---|
host | Domain to Query |
ips | The resolved IPv4 result of the domain, it’s a list, may contain 0, 1 or more IP address. |
ipsv6 | The resolved IPv6 result of the domain, it’s a list, may contain 0, 1 or more IP address. |
ttl | That domain resolve result TTL cache time |
origin_ttl | The original TTL for the domain name, i.e., the TTL value for the domain name configured on the authoritative NS. |
Error code:
Error code | HTTP Status | Description |
---|---|---|
MethodNotAllowed | 405 | The HTTP request method is not allowed. |
MissingArgument | 400 | Missing query parameters, such as host. |
UnsupportedType | 400 | The URL parameter type specifies a type that is not supported. |
InvalidHost | 400 | The URL parameter host specifies an invalid domain name. |
InvalidIP | 400 | The client IP specified by the URL parameter IP is invalid. |
InvalidQuery | 400 | The version of IP specified by the URL parameter query is invalid. |
InternalError | 500 | Server internal errors. |
QueryError | 500 | Domain name search error. |
Query examples
Example of a single result query: A single result query when only a single host and a single IP are specified.
- Request Example 1:
http://www.test.com:80/?host=www.a.com
- Request Example 2:
http://www.test.com:80/?host=www.a.com&ip=1.2.3.4
- Request Example 3:
http://www.test.com:80/?host=www.a.com&ip=1.2.3.4&query=6
- Request Example 4:
http://www.test.com:80/?host=www.a.com&ip=1.2.3.4&query=4,6
Response examples:
{
"client_ip": "1.2.3.4",
"ips": ["127.0.0.1"],
"host": "www.a.com",
"ttl": 300,
"origin_ttl": 300
}
Example of a multi-result query: A multi-result query when multiple hosts or multiple IP are specified.
- Request examples 1:
http://www.test.com:80/?host=www.a.com,www.b.com
- Request examples 2:
http://www.test.com:80/?host=www.a.com&ip=1.1.1.1,2.2.2.2&query=4,6
- Request examples 3:
http://www.test.com:80/?host=www.a.com,www.b.com&ip=1.1.1.1,2.2.2.2&query=4,6
- Request examples 4:
http://www.test.com:80/?host=www.a.com,www.b.com&ip=1.1.1.1&query=4,6
Response examples:
{
"dns": [{
"client_ip": "1.1.1.1",
"ipsv6": {},
"host": "www.a.com",
"ttl": 300,
"ips": {}
}, {
"client_ip": "2.2.2.2",
"ipsv6": {},
"host": "www.a.com",
"ttl": 300,
"ips": {}
}]
}