AFP548 Changing the world one server at a time.

Customizing virtual hosts

Home › Forums › OS X Server and Client Discussion › Web › Customizing virtual hosts

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #366021
    gshenaut
    Participant

    I want to have custom UserDir and ScriptAlias defines for each virtual host. That is, for two hosts x.x.x and y.y.y on one server, the urls http://x.x.x/~joe and http://y.y.y/~joe would expand to two different directories (e.g., /Users/joe/Sites/{x,y}). Similarly, executable cgi files accessible from site x.x.x will not necessarily be accessible from site y.y.y and vice versa. Before OS/X server, I just had one big hand-maintained httpd.conf, and this was easy. But from inspecting /etc/httpd, it appears that each virtual host is now in a seperate file and is generated by Server Admin.

    In the main httpd.conf file, it encourages a certain amount of hand customization, but I don’t know whether this also applies to the virtual host conf files. What would really be annoying is to make & test a bunch of customizations that suddenly stop working because of being overwritten by Server Admin.

    Maybe one way to do this is to insert an Include line in each virtual host file, and put the customizations in separate files. At least that way, the fix would be easier. But I’d like to know how vulnerable those conf files are to Server Admin.

    Has anyone done this before? What were the results?

    Greg Shenaut

    #366024
    gshenaut
    Participant

    Providing a little more information. I noticed that the Include line in the main httpd.conf file includes sites/*.conf. Ab initio, the directory contains one file for each virtual host, plus a file called virtual_host_global.conf. The individual site files’ names are of the form <index>_<ip address>_<port>_<site dns>.conf, where index is a 4-digit zero-padded index, and ip-address, port, and site dns are what you would expect.

    I put the customization into a file called 00000-zzz.conf and restarted apache. After a bit of tweaking, it seems to work. I also tried calling the file zzz.conf (so it would be read after the Apple-generated virtual host files), and that didn’t seem to work, although I admit I didn’t try too hard to figure why. My guess is that it’s the first definition of each variable that counts and redefinitions are ignored, but I couldn’t find anything in the documentation that dealt with this.

    Then I went into System Admin and made a minor change in the Web module and saved it. Sure enough, the entire sites directory was rewritten, and my customization file disappeared. I had to copy it back in and restart apache.

    So, it may be possible to use this band-aid method, but it is fragile. For the moment, each user has host-specific personal websites, but I don’t know yet if I broke anything by doing it.

    I’d still appreciate any knowledge about this anyone has to share.

    Greg Shenaut

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.