Skip navigation

Problems with virtual hosting.

545 Views 4 Replies Latest reply: Jun 24, 2011 1:40 PM by StephenM RSS
apple_customer Level 1 Level 1 (45 points)
Currently Being Moderated
Jun 2, 2011 4:42 PM

Hi, everyone.

 

My server configuration doesn't seem to be handling virtual hosting properly. My server is currently hosting several domains using a single IP address. For some reason when I do a search on Google it brings up one domain name associated with another domain's website. Let me be clearer.

 

When I do a search for my name on Google it returns different results. One of the results is the name of the primary domain (and respective website). I also host a secondary domain (virtual domain) that is actually my name on the same server (among many other virtual domains it is hosting). Google results show the name of the business hosted under the primary domain but the link is actually the secondary domain for my name. Does it make sense ?

 

When I do a search under 'FirstName LastName Title' it shows:

 

My Business

Mdsngmsd mksdnfmsdn dsmfnsdfn m,sdnfsdmnfsdfdfn sdfksdnbfksd

Sdbfkjsdnfmnkldl kdflkl lmfdmsdf lmdflm fdslkmlfmd

Ndsfnlkdsnflksdf ...

johndoemd.com

 

Why is it associating one domain name with another ? The last line above should instead read 'MyBusiness.com' which is the name of the domain associated with the website hosted as the primary domain for my server.

 

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.

 

This is how I have DNS set up in Server Admin under Zones:

 

Name = domain2.com. / Type = Primary Zone / Value = -

    Primary Zone Name = domain2.com.

    Admin Email = admin@domain2.com.

    Nameservers: Zone = domain2.com. / Nameserver Hostname = a.b.c.

    Mail Exchangers: Hostname = mail.domain2.com. / Priority = 10

Name = domain2.com. / Type = Machine / Value = (192.168.2.x)

    Machine Name = domain2.com.

    IP address = 192.168.2.x

Name = mail.domain2.com. / Type = Machine / Value = (192.168.2.x)

    Machine Name = mail.domain2.com.

    IP address = 192.168.2.x

Name = www.domain2.com. / Type = Alias / Value = domain2.com.

    Alias Name = www.domain2.com.

    Destination = domain2.com.

 

This is how Zones are set up for all domains, the single primary domain and all other secondary (virtual) domains.

 

Is this right ?

 

After verifying my settings I noticed in Server Admin under the 'Add Zone' pull down menu that one can choose 'Primary Zone' or 'Secondary Zone'. Should primary zone be used for the primary domain and secondary zone be used for all other virtual domains ?

 

Any ideas as to why I am experiencing this problem ?

 

Thank you in advance for your help and suggestions.

 

Joe

  • MrHoffman Level 6 Level 6 (11,695 points)
    Currently Being Moderated
    Jun 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.

  • StephenM Calculating status...
    Currently Being Moderated
    Jun 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

  • Camelot Level 8 Level 8 (45,670 points)
    Currently Being Moderated
    Jun 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.

  • StephenM Level 1 Level 1 (110 points)
    Currently Being Moderated
    Jun 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.

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.