2

I've managed to get 2 subdomains working following the second post in this thread, but it only works for Apache.

I would like to have a subdomain pointing to a certain service running on the server. For example I have a Cod4 (port 28960)and a Minecraft server (port 25565) running. Both are accessible by entering domain.com. I would like to change it so you have to enter cod.domain.com and mc.domain.com to enter the server. It should refuse access if you just enter domain.com (although it should still give you the site if you enter it using the browser).

Is this possible and if so, how? Using Google I was not able to find any tutorials. I could only find tutorials for Apache (which is not what I want).

Using Ubuntu 10.04 x64.

1
  • Do you want user come to cod.domain.com on port 80 or 28960?
    – 2707974
    Mar 26, 2014 at 9:34

1 Answer 1

2

This isn't how DNS works. For websites (and their servers) here's how things work:

  1. User punches in askubuntu.com
  2. Browser requests a resolution from domain name to IP from the operating system's networking stack
  3. This trickles through to the registrar which links to the nameservers for the domain
  4. The nameserver provides an IP back along the chain for the browser
  5. The browser connects to the IP (implicitly on port 80) and sends a GET request:

    GET / HTTP/1.1
    Host: askubuntu.com
    
  6. If the server daemon supports it, it will look at the Host segment before deciding which virtualhost to process the request as.

This is how you can host multiple websites off the same IP address.

But HTTP and its servers are special; this domain-aware requesting was developed over many years. Most server daemons don't care about DNS. All they really care about is what interface or IP and port they're hosted on and where they allow connections from.

This is the case of a COD4 or Minecraft server. They are told what interface and port to host on but that's it. When a COD4 client connects, it's doing the same DNS resolution (up to part 4) but the client isn't sending the domain name and the server wouldn't care if it did.

In short, you could stick in any domain that resolved to your game server's IP.


The only way to make this work the way you would want is to make sure your subdomainless domain name points to a different IP address of your game servers. You could do that. Most hosts allow the purchase of additional domains so you could have:

  • example.com and www.exmaple.com on 1.1.1.1,
  • cod.example.com on 1.1.1.2, and
  • mc.example.com on 1.1.1.3

Is any of that worth it? No. Plus it's frankly a waste of IPv4 IPs which are already a scarce resource.

1
  • That's a shame, but thanks for your answer! I'll just give up on this then...
    – PureTryOut
    Mar 26, 2014 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .