What are the right DNS records to host more than one site on OSX Server (ML). My conf in Server.app looks right but one of my sites lands on the default server. Any suggestion?
Currently Being ModeratedRe: What are the right DNS records to host more than one site on OSX Server (ML). My conf in Server.app looks right but one of my sites lands on the default server. Any suggestion?Oct 14, 2013 9:27 AM (in response to Ma_Per)
The key detail here is the DNS translations available at the web client (browser), and not the DNS translations at the web server; the web client sends over the target web site as a text string embedded within the HTTP or HTTPS traffic, and this string allows the web server to determine which virtual host should be displayed to the client. Put another way, the DNS configured at the web server is not relevent to the selection of the virtual host.
For publicly-served DNS and web server hosts using NAT, you're probably also going to be dealing with two sets of DNS servers. The public DNS servers and (unless your DNS has been delegated, which is rare) your own NAT'd network private DNS servers. Both pools of DNS servers have to have correct info, though not necessarily the same translations.
If you haven't already found these two documents, please take the time to skim this for DNS server setup and skim this for Apache virtual hosting (Sites) set-up. Those two web pages are detailed set-up information for DNS on OS X Server (you'll also need to set up public DNS separately, if you're exposing these web sites) and for setting up virtual hosts. They're written for 10.6, but still applicable to how DNS and Apache works even on the newer releases.
After you've skimmed those, please wander back with any questions you still have, and I'll answer those to the best of my ability, and (if appropriate) update the articles to address the issue.
I usually use DNS CNAME (alias) records for the virtual hosts, as well.
FWIW, main.com, sitea.com and siteb.com are all real and registered sites. Example.com, example.org and example.net are RFC-reserved domain names available for use in documentation, for obfuscation, and other related purposes.
Currently Being ModeratedRe: What are the right DNS records to host more than one site on OSX Server (ML). My conf in Server.app looks right but one of my sites lands on the default server. Any suggestion?Oct 15, 2013 1:11 PM (in response to MrHoffman)
My problem ended up being a name but not in the DNS!...In Apache.
Your information allowed me to rule out possibilities and zoom in to the culprit faster.
I just report here the conclusion hoping it can help someone else.
When I installed OSX Server last week, I had in mind to principally run siteb.
During the initial install, this is what I must have entered and then forgot about it.
Then I defined my virtual hosts sitea and siteb and realised my machine was called siteb and changed its name to main to avaid a name collision. At which time I remember OSX Server telling me that changing the name could have consequences...But it apparently went ok, and it did except for one little thing.
The consequence was this:
in the main configuration file /Library/Server/Web/Config/apache2/http_server_app.conf the ServerName directive had remained siteb (instead of main). I manually updated it with TextEdit (could do vi from bash, its the same) and replaced siteb with main.
There is a way to detect it.
In Server.app, there is a "logs" panel, which displays all sorts of logs for everything including the websites.
Each website's logs are presented as "access" and "error" logs. The information was there, but I could not see it because the viewing window in remarkably small for so much information in raw text...
web logs are actually written to only two files in /var/log/apache2 (error.log and access.log)
I openned two bash windows and run tail -f on error.log in one and tail -f access.log in the other.
When I started the web service, apache threw a warning stating from mod_ssl saying that the certificate did not match the serve name...I the certificate was what I expected, I checked http_server_app.conf and found the ServerName directive that was not changed when I renamed my server...
Easily fixed when its found, but it can take a while to find.
BTW, I was using A DNS records for and it works, but I find your method of using CNAME records documents the administrator's intent better than with A records; I started to do the same. (A records a useful though, they can run a domain across multiple machines)