How to host different machines with different subdomains?
I have what I regard as a fairly straightforward solution, though I'm the first to admit that it is not a high-performance one. Since I am on ADSL, information from my home server is down-loaded at my up-load speeds, so performance is not a primary concern.
- Because I already had it, I used a small web-site on a public host (equivalent to
myname.Public.Host
in your example). - My domain registrar offers a minimal package of domain registration and web-site / e-mail forwarding.
- I forward my primary domain to the public web-site (
myname.Public.Host
). - I use web-site folders, rather than subdomains to address my home servers, so that (using your example) I would address the cloud server with
www.myname.tk/cloud
, though I see no reason that a CNAME record forcloud.myname.tk
can't point to the same address (myname.public.host/cloud/
), though I haven't tried it. - I create
myname.public.host/cloud/index.htm
containing the following code (I'm sorry, I can't acknowledge the source of this code, as I've lost the reference):
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>AFH - Web Server Home</title> <META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://myname.Dynamic.DNS/cloud"> </head> <html>
- This is how I use it, but for my WebCam I use
URL=http://myname.Dynamic.DNS:WebCamPort
: my router is able to mapWebCamPort
to80
on the WebCam's IP, and this seems to work well: although I'm using ports, this is completely transparent when the site is accessed aswww.myname.tk/WebCam
. - In principle, you can use the same technique, so
myname.public.host/cloud/index.htm
would transfer you toURL=http://myname.Dynamic.DNS:CloudPort
, etc, and the different ports provide you with a simple way to address the different servers on your intranet.
In summary, cloud.myname.tk
would be forwarded to myname.Public.Host/cloud/index.htm
and from there transferred to http://myname.Dynamic.DNS:CloudPort
and then through the router to your cloud server.
As a final note, I at one time had difficulty in finding a reliable dynamic DNS server, so I implemented my own, by running a script every five minutes which checks my home's public IP and, whenever this changes, calls an FTP script to update the index.htm
files in each of the folders, replacing URL=http://myname.Dynamic.DNS ...
by URL=http://my.pub.IP.addr ...
(this is easy in Linux, but more of a challenge on Windows, where my web server resides).
From the length of this answer, you may question its straightforwardness, but each of the stages is pretty simple, and I gradually arrived at this solution step-by-step, and it now works reliably. You should check that you can create the appropriate CNAME record before you do any more work on implementing it.