I've asked this question previously at serverfault.com (what I believe to be the more appropriate site for this question, however, it was closed unanswered moments later and I was referred here. My question, I have 5 services running on one server. A webportal to a torrent client on port 8112, a Minecraft server on 25565, a Plex media server on 32400, and apache2 running on port 80. I currently have a subdomain of a domain I own from godaddy, pointed to my home ip address. Everything works fine that way. However, I'd like to have multiple subdomains for each service, but not have them all resolve by just changing the port. For example. Right now, if I were to go to minecraft.myaddress.com:32400, I'd be forwared to the plex media server. Is there a way to keep subdomains from resolving if not the correct name?

  • You want the same IP having several names? That can certainly be done, just do it the same way you did for the first one. If that isn't your question, please edit it to make clear what you are after. – vonbrand Feb 10 '13 at 19:52
  • The reason this is off-topic on SF is that SF is intended for professional sysadmins; if it's not something someone would normally be paid to do, it's likely to be off-topic there. – cpast Feb 10 '13 at 20:04
  • @vonbrand: It seems fairly clear to me what he's after. He seems to be asking for port-dependent DNS resolution; for example, if you try to connect to minecraft.myaddress.com:32400, he doesn't want it to resolve to his home IP address. I assume what he's really after is to make minecraft.myaddress.com:32400 not work to connect to the media server, so that you have to know to connect to plex. in order to reach the media server (for example) – cpast Feb 10 '13 at 20:08
  • @cpast, that is port-forwarding somewhere along the line, i.e., extra machines. And I believe that isn't what OP has in mind. "Resolve to IP only for <port>" just isn't anywhere near what DNS can do (no, it can't be fixed, DNS just doesn't get chapter and verse on why a process is asking for a particular FQDN --> IP mapping, and has no control of what the process does with it afterwards). – vonbrand Feb 10 '13 at 20:11
  • @vonbrand, I think the confusing part is "multiple subdomains for each service". I think he meant "multiple subdomains, one for each service". – cpast Feb 10 '13 at 20:16

No, there is not. The way connections work is that the person connecting first looks up the IP address for that domain name, and only once they get the IP address do they make the connection attempt. The port number only comes into play on the second part; DNS maps domain names to IP addresses, and doesn't know or care what port you plan to connect to.

That said, depending on the protocol, you may be able to configure the server on your box to only serve to the "right" domain names. I know that Apache can be set up to serve different content from the same IP depending on what domain name was entered in, and I believe mail servers are similar. However, this is only possible because HTTP sends the domain name once the connection is established; in general, though, the domain name is only used to find the IP.

  • The HTTP protocol includes the target domain in its queries, that is the way a web server can answer to different domains on the same IP with different contents (result of early webhosting, where each domain had to have its own IP, and IPs were starting to get scarce...). The other protocols about which OP asks don't. – vonbrand Feb 10 '13 at 20:18
  • @vonbrand Also, HTTP's inclusion of the domain lets you run a website with multiple subdomains (I actually administer a server that does this: my school's single webserver serves www.school.edu, newspaper.school.edu, directory.school.edu, etc.) [and if you look at the second paragraph, I already said HTTP does this] – cpast Feb 10 '13 at 20:22
  • Well, let state this. If I had three separate physical boxes. 192...1, 192...2, 192...3. Each hosted a separate service. I.e. media server, web host, minecraft. I could setup a virtual host file in apache to forward the request to the correct server. But the services are instead on one box. – Nicholas Feb 11 '13 at 9:23
  • @Nicholas: No, you can't set up Apache like that. Apache only handles HTTP requests. Anything using a different protocol can't be handled by Apache. For example, Minecraft uses its own protocol, and Apache can't handle that. Virtual hosts only work because of a very specific feature of HTTP, a feature which isn't present in all other protocols. – cpast Feb 11 '13 at 23:28

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.