I'm running a web server on port 80 and another on port 87.
I would like to use DNS so that www.example.com goes to port 87.
How can I accomplish this using DNS only?

Canonical Question: This question was originally asking about running IIS and Apache on the same server, but the same concepts can be applied to any server software receiving connections from clients. The Answers below describe the technical problems with using DNS to assign a port number for a client to connect.

link|improve this question

61% accept rate
feedback

5 Answers

You cannot use the DNS to point to a port. You will have to put some other method in place to do this. Typically you would use a front end webserver (or a dedicated proxy server) to proxy the connection from port 80 to port 100 based on the name of the server being requested.

link|improve this answer
Ouch, shit! When you all, at last, begin RTFM? And use brain for writing funny SRV records?! – Lazy Badger Jan 26 at 23:09
feedback

I'm afraid domain names can only be associated with an IP address and not a port.

Most web servers e.g. (Apache, IIS etc.) do allow you to have two domains hosted on the same IP address by using the fact that web requests contain a host-header field that identifies the domain in the request itself.

If you say what the web server is that you are using I'm sure people can point you to the relevant documentation to set up your server as you wish

link|improve this answer
That's the point. I'm using two different web servers. – Omar Abid Jan 26 at 14:21
feedback

DNS does not have the capability to redirect to a specific Port, all DNS cares about is the IP address resolution of a name, and vice versa.

Some services, such as Dynamic IP DNS providers, such as NO-IP provide a serivce that can help you do something similar to get round blocking of IP's on home DNS services.

link|improve this answer
Some registrars (GoDaddy) offer domain forwarding through their parked servers. You could give that a shot, but it's a bit of a kludge. Alternately, you could write your own web browser that looks up SRV records, and then try to convince the world to use it :) – Jason Antman Oct 14 '09 at 17:38
feedback

When you type http://www.domain.com into your browser, it is understood that the HTTP port is on 80. Therefore, there is no direct way to point www.domain.com to port 87 if you already have a service running on that port in IIS.

That being said, there are a few "workarounds".

  • Just use http://www.domain.com:87/ - this will connect to port 87 (apache) on your server.
  • You can set up a redirect, so that http://www.domain.com/apache will forward (or proxy, if you want to get fancy) to www.domain.com:87.
  • You can set up a "VirtualHost" so that www.domain2.com will still be on port 80, shared with www.domain.com. You can not set this up without modifying IIS.

Sam is right, DNS is agnostic when it comes to ports. Any sort of port redirection happens by the service that is running on that port. Therefore you would need to do something with IIS to make this happen, if you have no choice but to leave it on port 80.

I've also gotten around your situation by using mod_proxy on Apache, not sure if there is a way to do this with IIS.

link|improve this answer
Ok, so how to set proxy on IIS ? – Tomaszs Oct 14 '09 at 13:47
If it's IIS7, you can use Application Request Routing (ARR). – Scott Forsyth - MVP Oct 14 '09 at 13:50
feedback

In order to use any (TBT) service on non-standard port and don't write port in URI, everybody can use SRV records, defined in RFC 2782.

_http._tcp.www.example.com. IN      SRV 0    5      87   www.example.com.

All other http-hosts in zone still will be served on default port 80

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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