home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] progress

On Fri, Apr 14, 2006 at 03:36:07AM -0400, sberaud wrote:
> I think,
> 
> At least I now have NamedVirtualHosts in Apache working correctly. I 
> needed the server alias directive to be set for each new virtual domain 
> - don't I feel silly.

Assuming you mean the ServerAlias directive... yeah, it's important that
you cover every single name that users might use to contact your virtual
host.  Typically that means "www.domain.com" and "domain.com".  Just
using "domain.com" isn't enough to cover "www.domain.com".

(Some purists insist on users using the "www." prefix as was
originally intended, but corporate presence on the Internet decided
that "www." was optional, and now pretty much the entire Internet
caters to that technical incorrectness.)

To avoid the confusion of getting the wrong host, I set up my servers
so that using the IP (or the hostname, e.g. "hostname.mydomain.com")
gets you a "default" site (/var/www/default).  This is like the host's
"personal" webspace, where we can put miscellaneous things for people
to download, server status pages, etc.

Accessing just plain "http://hostname.mydomain.com"; is an index of
these things from inside my network, or a 403 "forbidden" error from
outside.  This means it's abundantly clear if a domain is set up
incorrectly -- I get a directory index rather than getting another
"real" virtual site.

Then I set up virtual hosts for "www.mydomain.com" / "mydomain.com",
"www.hosteddomain.com" / "hosteddomain.com", etc.

> I also had my cname records like this:
> 
> www.mahshidfdimarco.com.    IN    CNAME    www.myservername.net.
> 
> but I suspect this is wrong and changed it to:
> 
> www.mahshidfdimarco.com.    IN    CNAME    mahshidfdimarco.com.

Well, neither is technically wrong, though of course the former relies
on "www.myservername.net" resolving.  Me, I typically do

	hostname	IN	A	1.2.3.4
	@		IN	A	1.2.3.4
	www		IN	CNAME	hostname

Note that I've left off the domains.  When you're defining a zone,
unless a name ends with a "." (meaning it's an absolute domain name),
BIND assumes that you're talking about a host in the zone you're
defining.  So "hostname" means "hostname.mydomain.com", and "@" means
"mydomain.com".  (Note that "@" cannot be a CNAME.)

In this way, you can actually use the same zonefile for multiple
domains.  This is what we do for our "generic" domains that all go to
the same web and mailserver.

Attachment: signature.asc
Description: Digital signature

references

message navigation