I am trying to figure out a way to give IP:PORT/SOMEPATH a DNS entry. For example we have multiple services as the URLs IP:PORT/APP1, IP:PORT/APP2, etc. Can I use DNS to alias these any way?

It looks like A records are for just IP, and SRV records can be used for IP:PORT: http://www.networksolutions.com/support/how-to-manage-advanced-dns-records/

Is this impossible with DNS? I guess the question is, can you alias any valid URL with some type of DNS record?

EDIT: this question is related but they specifically asked about CNAME records and I'm asking if there isany record type to achieve this: Can a CNAME DNS record point to a subdirectory

  • DNS A records do not (cannot) define port or path. Your web server (nginx, httpd, etc) would perform the desired redirection/rewrite. – jscott Sep 6 '16 at 14:26

With a modern web browser, you would use DNS CNAME records to give each application server a unique name all pointing at your web server. The web server would then use virtual hosting based on the Host: HTTP header that the browser passes in (in apache, the ServerAlias directive).

While DNS does have a URI record type, I don't know how widely that's implemented.


DNS only maps names to IP's, so no, you can't map protocols, ports or paths.

The normal way to do what you want would be to set up virtual hosts. This is where the web server looks at the content of the "Host" request header the client sends and directs the request to the correct application. You can then just make a different sub domain for each app and don't need to worry about ports.

You don't specify which web server you're using but 99% of them will do this.

SRV records will allow you specify the port a well known service running on but not an arbitrary application. They're not widely supported however (by web clients anyway).

  • what does tools.ietf.org/html/rfc7553 do? – Tommy Sep 6 '16 at 14:59
  • Well if it ever gets implemented it will do exactly what you want. You might be waiting a while though. – Nick Sep 6 '16 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.