7 Replies Latest reply on Nov 13, 2014 12:28 PM by rstory

    Virtual Hosts in Apache on OS X - Help needed

    rstory

      So I've got a bit of a conundrum and I was hoping someone might be able to help steer me right.


      FileMaker Server running on an OS X Machine (10.9.5) (Apache web server 2.2.26). I was able to template Apache Virtual hosts on a regular OS X webserver installation and get everything working fine, but now I'm trying to push it out and I'm bumping my head a bit because of the FileMaker Apache configuration.


      Basically, the client needs to serve two separate websites off of this machine. For simplicity, we'll call this www.site1.com and www.site2.com.


      For any Apache people who haven't really played around with the FileMaker configurations, here's what the lay of the land looks like. Basically, instead of HTTP Root being in /Library/Webserver/ it's in /Library/FileMaker Server/HTTPServer. From there you've got some subdirectories:

      /conf which has the httpd.conf and the /extra subdirectory.

      /htdocs which is the DocumentRoot folder for the default website (site1.com). Currently serving those files just fine.

      /sitetwodocs which is a folder I created, and then made sure that the ownership/permissions were identical to /htdocs. All I stuck in there was an index.html file that basically spits out "It's works! (this is site2)"

      /logs (not huge, but I don't want people dinging me on a technicality of referencing it without explicitly stating that it's there)


      So basically, apart from starting out in a different spot, it's looking like everything is basically in relatively the same place.


      After backing everything up, I did a sudo nano on the httpd.conf file in the conf folder and uncommented

      Include /conf/extra/httpd-vhosts.conf

      Then I went into extra/httpd-vhosts.conf and this is where things start to get a little spicy.

      Evidently, even though the httpd-vhosts.conf file wasn't being included in the httpd.conf, there was a slightly different file in there than I was expecting when I did a sudo nano on that file. Basically, they had a

       

       

      NameVirtualHost *:8080

       

      at the start but the <VirtualHost> defiinition was just the stock dummy-host.example.com stuff, so I was comfortable more or less ignoring it. It's listening on a different port, it doesn't appear to be harming anything at the moment, and I can worry about that once I get the port 80 stuff working.

       

      I added the following

       

      Code (text):

       

      1. NameVirtualHost *:80
      2. <VirtualHost *:80>
      3. ServerAdmin admin@site1.com
      4. DocumentRoot "/Library/FileMaker Server/HTTPServer/htdocs"
      5. ServerName www.site1.com
      6. ServerAlias site1.com
      7. ErrorLog "/Library/FileMaker Server/HTTPServer/logs/site1.com-error_log"
      8. CustomLog "/Library/FileMaker Server/HTTPServer/logs/site1.com-access_log" common
      9. </VirtualHost>
      10. <VirtualHost *:80>
      11. ServerAdmin admin@site1.com
      12. DocumentRoot "/Library/FileMaker Server/HTTPServer/sitetwodocs"
      13. ServerName www.site2.com
      14. ServerAlias site2.com
      15. ErrorLog "/Library/FileMaker Server/HTTPServer/logs/site2.com-error_log"
      16. CustomLog "/Library/FileMaker Server/HTTPServer/logs/site2.com-access_log" common
      17. <Directory "/Library/FileMaker Server/HTTPServer/sitetwodocs">
      18. Options Indexes FollowSymLinks
      19. AllowOverride All
      20. Order allow,deny
      21. Allow from all
      22. </Directory>
      23. </VirtualHost>

      I did not remove any of the dummy-host.example.com Virtual Host stuffs for port 8080 because I didn't want to break anything on the FM Server in the off chance it needed it.

       

      I did a restart of the apache server by going to the bin/ directory and running a sudo ./httpdctl graceful command.

       

      So having accomplished this little bit I ran over to my main machine that was on the network and jimmied the hosts file and created a spoof forwww.site2.com to point to the same IP Address as site1.com, This was the formula I used while doing a proof-of-concept on another machine (using the OS X Apache configuration) and it worked fine.

       

      When I go to site1.com in my web browser, I go to the existing site, so I didn't break anything (apart from temporarily in the footnote below), but when I go to www.site2.com, it takes me to site1--it's not forwarding that domain request to the appropriate sitetwodocs DocumentRoot directory. Location bar shows site1.com

       

      When I looked at the site2.com-err_log file, I see lines like the following:

      1. [today] [error] [client mycomputer] client denied by server configuration /Library/FileMaker Server/HTTPServer/sitetwodocs/images, referer: http://www.site1.com/

       

      after monkeying around with the various configuration files (uncommenting the LoadModule vhost_alias_module /usr/libexec/apache2/mod_vhost_alias.so line in httpd.conf, stripping out the *:8080 configurations, etc) I was able to get exactly the same results (yes, I'm restarting apache after every configuration change), except this time, the error log is spitting out

       

      [today] [error] [client me] File does not exist: /Library/FileMaker Server/HTTPServer/sitetwodocs/images referer: http://www.site2.com/css/layout.css

       

      When I go to www.site2.com, it basically serves up site1, and the location bar says site1, but deep in the error logs, apache knows something is wrong, and it knows it should be using /sitetwodocs even though there is literally ONE html file in that directory that isn't referencing /css/layout.css or an /images directory.

       

      Most peculiar.

       

      Can anyone spot what I'm doing wrong and give an idea of how to fix it?