DNS and configuring subdomain

b4u

Golden Member
Nov 8, 2002
1,380
2
81
Hi,

I need some help with understanding the setup made when hosting a website and registering a domain for that website.

I'll assume 2 scenarios, which at the end may point to the same situation.

Scenario #1

I join a free host service, and upload my web page. Let's imagine the host is http://www.freehosting.com, and after registering for the service, I have the following address to access my web page:

http://mysite.freehosting.com <-- In here they give me a subdomain name
or
http://www.freehosting.com/mysite <-- In here they give me a sub-folder where I have my work

I don't like those names, and I want to create a domain of my own. So, I go to a registrar and create a domain named: mydomain.com

Now here comes my questions ... how will I link the domain name to the host service provider?

I mean, if my registrar gives me a DNS service (which some don't, but the vast maiority do, I think), they can give me their DNS id, something like:

ns1.myregistrar.com
ns2.myregistrar.com

Then I give them to my host provider? What will they do with them?

Shouldn't I just configured the host IP or something like that on the DNS server of my registrar? Something like point "www" A record to some IP my host gives me ...




Scenario #2

I'll have a server on my local network. It'll be behing a router, and on the router I'll forward port 80 to the server (which is 192.168.0.1).

On the server, I have many web applications. Let's imagine one for each user, for a total of 3 users, and another with the public webpage. I can access them on my local network using:

http://192.168.0.1/user1
http://192.168.0.1/user2
http://192.168.0.1/user3
http://192.168.0.1/www <-- This is the public webpage web application

(http://server.mydomain.local/... since my server is the machine name and mydomain.local is the domain name. LAN DNS resolve it nicely)

I go to a registrar and register the mydomain.com. Imagining that my registrar gives me a DNS service, I would like to point:

http://www.mydomain.com to the local LAN http://192.168.0.1/www
http://user1.mydomain.com to the local LAN http://192.168.0.1/user1
...

I imagine I could point "www" A record to my WAN IP, and I would have http://www.mydomain.com/www, http://www.mydomain.com/user1 ... working out-off-the-box ... but I would like to configure it as I said ... subdomain www to webpage, then user1, user2, user3 for each user webapp ...

It's a bit similar to the scenario #1. How will I do that? Do I have to do that on my LAN site? Where should I mess things up?



Those might be some simple/basic questions, but it's a bit that I'm missing to understand how this works and the setup involved.

Thank you
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
#2: Easy - like n0c said, you need virtual hosts. In other words, you tweak the web server configuration so that it serves up different pages depending on what name (i.e. sub1.domain.com, sub2.domain.com, etc.) it is being called. Both Apache and IIS can do this. I don't know IIS, but for Apache just look at httpd.conf and Google a bit. It's well laid out.

#1: This is harder. DNS alone won't help you - you can set up your domain on the registrar's DNS server, but all you could do is use the IP address of the webhost. Problem is that the webhost depends upon the name it is being called in order to determine what page to serve. So if someone looks up your new DNS record, they'll find the server at the correct IP but be calling it by your new name, which it doesn't recognize. What you need is something called an HTTP redirect. This is done by a web server which takes a request for one name and tells the client to look for a different name instead. Then the client will find the server and call it by a name it recognizes.

If you don't mind setting up your own web server, this isn't a big deal. Your actual site can be off your network at the webhost and you run a simple Apache server that does nothing but redirect requests to the webhost. That means your DNS for the new domain would point to your Apache server, which would in turn redirect requests to the webhost's name which the clients would do a new DNS lookup for.

Some places will handle this "web forwarding" for you. A quick Googling found this page at EasyDNS. I've never used any outside help for redirects, so I have no idea how widespread such services are among DNS outfits or whether there is any variation in quality or features.
 

b4u

Golden Member
Nov 8, 2002
1,380
2
81
About #1

I don't quite remember where I saw it, but when I registered for a host service, I got some info about using my own domain name instead of their free-but-subdomain name.

Something like using http://www.mydomain.com instead of http://mysite.freehosting.com.

I don't know if I'm remembering correctly, but I believe they (the host service) gave me a list of DNS servers (their own) to use on my registrar ... something like that.

So the theory would be to forward a DNS from registrar to DNS of the host service? Using something like a CNAME?

Sorry to ask this again, but it seems so easy from hoster/registrar point of view, with such a quick way of setting it up, that looks like an automatic way of configuring the job ...
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
If the hosting company will let you use your own domain name for some free site, ask them how to set it up. ;)
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Originally posted by: b4u
So the theory would be to forward a DNS from registrar to DNS of the host service? Using something like a CNAME?
My limited testing may be wrong, but I don't think that a CNAME helps you in this situation. It would work if the webhost were serving only a single site (i.e. every request to its IP gets the same page). But your webhost figures out the page to serve based on the hostname it is being called, and a CNAME doesn't change the name in the client's HTTP headers.

For example, if I go to webmail.mydomain.com, I find the correct IP address for "webmail" through a CNAME to the host's canonical name "aristotle". But the HTTP request still uses "webmail" for its host field. For me, that's fine because the webmail server is configured to look for "webmail" as a possible host name. For you, it won't work (at least not yet) because the hostname in the HTTP request won't be recognized by the webhost. If a hosting company is saying this will work, then I'd guess that they're taking the step of configuring the virtual host on their machine as well. That works fine so long as they're willing to do that, but I don't think that a DNS CNAME alone is going to cut it. So make sure the hosting provider will do this - like n0c suggested, talk to them.

And again, I'm not absolutely certain of this. It seems accurate to me, though...
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Originally posted by: b4u
Sorry to ask this again, but it seems so easy from hoster/registrar point of view, with such a quick way of setting it up, that looks like an automatic way of configuring the job ...
And yes, it's easy. Like I said, some hosting companies provide the service and it's not hard to set up provided that they support it and that you use their tools. But you're asking about the theory of it, and the theory is a bit more complicated than just providing a DNS CNAME.