大网数据广告活动
服务器运维问答

How to use URI DNS record with HTTP?

· 52CE 我爱测

I'm trying to use a URI record with HTTP https://en.wikipedia.org/wiki/URI_record On Cloudflare I put sub in Name and https://example.com/page/ in Content yet if I go to https://sub.example.net it says curl: (6) Could not resolve…

问题原文

原帖链接 · sweetprogrammer · CC BY-SA 4.0

I'm trying to use a URI record with HTTP https://en.wikipedia.org/wiki/URI_record

On Cloudflare I put sub in Name and https://example.com/page/ in Content yet if I go to https://sub.example.net it says curl: (6) Could not resolve host: sub.example.net

已采纳解答

原帖链接 · Esa Jokinen · CC BY-SA 4.0

The purpose

The purpose of RFC 7553 URI records is not to replace HTTP redirection, but to complement S-NAPTR (5.2), replace U-NAPTR (5.3) and replace SRV (5.4) record types. I think the intended purpose is best expressed in section 2:

In general, it is expected that URI records will be used by clients for applications where the relevant protocol to be used is known, but, for example, an extra abstraction is needed in order to separate a domain name from a point of service (as addressed by the URI). One example of such a situation is when an organization has many domain names but only one official web page.

Just like with the SRV records, this requires that an application is designed to use URI records for finding this information. Web browsers aren't following URI records and won't even try and resolve them. The HTTP protocol doesn't utilize URI records at all, and web browsers are following the protocol.

Usage

As Michael Hampton mentions in comments, neither have I ever seen a service, a protocol or an application using URI records. E.g. the Wikipedia article for SRV records has Usage section listing some protocols that are utilizing the SRV resource record type, but the article for URI records doesn't even have a similar section as of July 2020. Nobody uses this record type.

The syntax

The section 2 continues:

Applications need to know the specific service to prepend the hostname with.

and there's an example given in section 5.1:

An organization has the domain names example.com and example.net, and their FTP archive is at ftp://ftp1.example.com/public. Given the service name ftp and transport protocol tcp (from the IANA "Service Name and Transport Protocol Port Number Registry"), the following URI resource records could be made available in the respective zones (example.com and example.net):

$ORIGIN example.com.
_ftp._tcp    IN URI 10 1 "ftp://ftp1.example.com/public"

$ORIGIN example.net.
_ftp._tcp    IN URI 10 1 "ftp://ftp1.example.com/public"

Let's imagine for a moment that web browsers had adopted RFC 7553 URI records. In that case, the URI record for HTTP service for sub.example.net would be under _http._tcp.sub.example.net:

_http._tcp.sub.example.net. IN URI 10 1 "https://example.com/page/"

What you had configured wouldn't have a chance to work as expected because of syntax error.

How to achieve your desired functionality

In general you would need to create a HTTP/HTTPS service on sub.example.net that replies with either 301 Moved Permanently (RFC 7231, 6.4.2) or 302 Found (6.4.3) and Location (7.1.2) containing the https://example.com/page/; in short, HTTP redirection.

With Cloudflare, HTTP redirections can be configured using Cloudflare Page Rules.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-07-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。