I have some REST services available with on an ip+port address. Now I want to configure a DNS entry to have it available through my domain. I've tried a masked redirect but once I do it I can't access the REST services using the redirected address. What type of DNS entry should I use?
2 Answers
DNS only works at the IP Address level, its only concern is mapping domain names to IP Addresses, there is no way to specify a port number.
If you have a server located at 12.34.56.78, you can use an A record to point to it. There is no way to specify a port in DNS.
Edited to add
While RFC 2782 A DNS RR for specifying the location of services (DNS SRV) does provide a method to use Srv records to specify port numbers, it was ultimately allowed to expire and was never renewed.
Specifically the proposal was rejected because it could break too many things in the HTTP layer.
A message was posted to the IETF message boards explaining the decision.
I was proposing it, but after long discussions in the maillist I've understood that mandating DNS SRV in WS clients would break too much assumptions in HTTP world (which commonly just sees above HTTP layer and not below).
The existence of HTTP proxies is also a big handicap since those proxies should be upgraded/modified in order to perform DNS SRV resolution just in case the HTTP request is a WebSocket handshake. This last argument is enough to not mandate SRV resolution.
(copied from another answer)
-
This is actually incorrect. See the other answer. SRV records certainly use ports. Whether it's practical or useful is another matter. – Evert Apr 20 '16 at 16:08
-
@Evert I have amended the answer – Michael B Apr 20 '16 at 17:51
-
@MichaelB-AzureMVP It's not RFC 2782 that expired but a proposal (in fact two) to introduce `SRV` records to HTTP. These efforts have been discontinued due to the problems mentioned in your quoted message. `SRV` records themselves are quite alive, though. E.g. SIP and Jabber/XMPP services are using them. – DaSourcerer Apr 20 '16 at 20:19
-
@DaSourcerer I realise that SRV records are quite alive, however this question is specifically about REST (i.e. HTTP) requests and hence SRV records have been discounted for the purposes of this question. – Michael B Apr 20 '16 at 20:23
-
@MichaelB-AzureMVP No objection to that. But your answer seems to imply it were the RFC for `SRV` records themselves that expired; not the proposals specific to HTTP. You also seem to be under the impression I were advocating the use of said records to solve the problem at hand. That is not true: I wanted to show that (a) there is indeed a way to specify ports for a given service through DNS, (b) that this way is not suitable for HTTP and should be avoided, and ultimately (c) the (IMHO correct) way were to explicitly set the port in the request URL. – DaSourcerer Apr 20 '16 at 20:38
There actually is a mechanism called DNS Service Discovery originally specified in RFC 2052 (obsoleted by RFC 2782). This allows for autodiscovery of services through special SRV
(type 33) DNS entries, specifying ports and weights (i.e. preferences) for named services. There were some considerations extending this to HTTP URIs, but the respective drafts have ultimately been allowed to expire before they could reach RFC status. Some of the reasons are being mentioned in section 2 of latter one.
While SRV
records are seeing active usage in other protocols, HTTP client support for this is quite rare. So if you want to provide your service through a dedicated, non-standard port, your best bet is to specify it in the URL as specified in RFC 3986, section 3.

- 1
- 1

- 6,288
- 5
- 32
- 55