Currently Being ModeratedJun 2, 2011 6:24 PM (in response to apple_customer)
Apache Virtual Hosts are based on the DNS in place at the web browser; the web client.
Not the DNS services active at the server.
Your local DNS services are largely irrelevant to remote (public) access into your web server, though they're definitely relevant to local activities (other than remote connections into your public-facing web servers).
Given you're operating behind a NAT gateway, you do need functional local DNS, and some details on setting up DNS on Mac OS X Server. Get that going before the rest of the applications and services, as things can get weird otherwise. (Yes, you do need DNS services somewhere on your LAN, either on your server somewhere on your LAN.)
No, your ISP DNS is not capable of translating host names for servers and clients located behind NAT, and no you cannot reference your ISP DNS servers.
If you want to confirm that your DNS is working or not, launch Terminal.app and issue the command sudo changeip -checkhostname command. You'll get an indication that no changes are needed, or that DNS services need changes.
As for getting Virtual Hosts working and once you have your private DNS going (and then more importantly, getting public DNS going), and some details on setting up Apache virtual hosts.
And one other detail to confirm. Within the web server settings within Server Admin, make sure you don't have web host aliases set.
Currently Being ModeratedJun 24, 2011 8:14 AM (in response to MrHoffman)
BTW. Virtual hosting can be set up and function wonderfully through Server Admin if you don't feel like mucking with setting up a Apache virtual host. Server Admin just sets up a nice GIU to make change at a higher level.
Server Admin>>Choose Server>>Web>>Sites
Currently Being ModeratedJun 24, 2011 12:40 PM (in response to apple_customer)
The above comments notwithstanding, there's one outstanding line in your post that seems crucial:
Also if I type on my browser the name of another secondary (or virtual) domain name in the form http://domain2.com it brings the website hosted under the primary domain which is domain1.com. In case I type http://www.domain2.com than it works as it should and displays the website hosted under this domain name.
As far as Apache is concerned, 'domain2.com' and 'www.domain2.com' are completely separate entities. They have to be otherwise if all domain2.com traffic went to this site you'd never be able to host different sites within the domain (e.g. blogs.domain2.com, wiki.domain2.com, blah.domain2.com, etc.). In other words, there is no automatic relationship between a hostname and sub-records of that hostname.
So what's happening here is Apache is seeing a request for 'domain2.com' which does not match any of its configured virtual hosts, so it handles the request via the default site. If you request www.domain2.com this matches your virtual host configuration so Apache serves the alternate content.
The fix is simple - trivial, even - you just need to tell Apache all the hostnames that match this site - in this case if you've configured the site's primary address as 'www.domain2.com' and you want it to also respond to requests to 'domain2.com' then add 'domain2.com' to the list of Server Aliases in Server Admin.
Currently Being ModeratedJun 24, 2011 1:40 PM (in response to apple_customer)
I missed the part about web sites redirecting to the primary site previously. This is likely due to the fact that there is a wildcard in the web alias panel. When that happens, all virtual domain requests still get routed to the primary domain.
This is from the Web Administration documentation provided by Apple:
"By default, the Sites Aliases panel lists a Web Server Alias * (wildcard) directive. To perform name-based virtual hosting, remove the wildcard. If you do not remove the wildcard, browsers trying to access your virtual hosts will access the default host instead."
To change that, go to
Server Admin>>Choose Server>>Web>>Sites>>Aliases.