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?
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
plex.
in order to reach the media server (for example) – cpast Feb 10 '13 at 20:08