Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm confused about virtualhosts and DNS. Apache2. 1

Status
Not open for further replies.

SimonDavis

Technical User
Mar 16, 2001
613
GB
Wonder if someone can clarify this, I've spent a while trying to pin it down.

I have a domain, (lets call it mydomain.com).

The DNS records for it all specify just mydomain.com, not or anything else.

I am innocently assuming then that any request for something on that domain will be forwarded to my server - but works fine, but anything else, say test.mydomain.com doesn't.

I have tried adding some virtualhosts, but to be honest it's confusing. Whatever I do, others don't.

Is this a dns issue (and if so, why does and others not), or am I maybe messing up the virtualhosts entries in the apache config file?

Thanks for reading!
 
Each name you want to access the web server by must have a dns entry. They can share the same IP address or be aliases (CNAME records), but they all have to be in DNS. I think you will find that yourdomain.com and are both in DNS.

Virt hosts work because in the request phase of the HTTP connection the browser sends the HTTP request:

GET /whatever.html HTTP/1.1

Then sends:

Host: whatever.yourdomain.com

Notice the GET doesn't specify the hostname, but the next line tells the web server what host it wants to talk to. That's why they can share an IP address. Note: SSL requires a dedicated, unshared IP address in Apache.
 
OK - thanks for the reply, so I need to get the DNS entry changed (or even a new one) each time I add what I (maybe wrongly) call a subdomain, right?

I kind of suspected this, but the confusion is becuase I can't actually find the anywhere when browsing around DNS records. Would it make sense that maybe its my ISPs nameservers that do that part then?

Anyway, thanks a lot for your help!
 
Yes, if you want to handle test.yourdomain.com as a different virtual host, you need to add it to DNS.

It could be your ISP, if you posted your domain I could tell you. It could be your browser. A lot of browsers will stick a .com after a hostname that doesn't have one and stick a front of a hostname if it can't get a reply from the host without it.
 
OK, promise not to laugh . . .


I make no apologies for the crappy wesite on it, I'm letting a friend practice his l33t HTML skills while I get my head around webservers!

Anything you could tell me would be interesting. Thanks.
 
Eric,

Thanks for the Info - would that mean I could have different sites on and just bollockbrains.com.

Strikes me as I'm writing this I should just try it and see . . .

Appreciate your input anyway, I am now just a little further down the road!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top