4 Replies Latest reply: Feb 14, 2013 1:28 PM by zzTontozz
macmartin Level 2 Level 2 (495 points)

Hello together,

 

how can I manage my virtual hosts on Lion Server e. g. add some directives to the configuration.

 

I created some VirtualHosts with Server.app.

The configuration files reside in /etc/apache2/sites and usualy I would just edit an add directives directly.

 

But in /etc/apache2/ReadMe.txt it says:

 

Administrators are strongly encouraged to use the webapp mechanism instead of modifying virtual host config files directly. In general, you can place Apache configuration directives in an "Include" file, and create a webapp.plist file that references that Include file. You can then activate or de-activate that Include file using webappctl(8).

 

How does this work?

The manpages didn´t help.

 

How could I for example add a ScriptAlias directive safely?

 

regards

macmartin

  • 1. Re: Managing Virtual Hosts on os X Server 10.7
    zzTontozz Level 1 Level 1 (0 points)

    Did anyone help you with this? I am interested in this as well but in relation to Mountain Lion Server.

     

    I wanted to specify something like:

     

    Order Allow, Deny
    Allow from 192.168.0/255.255.255.0
    Deny from 192.168.0.1

     

    so as to restrict apache to responding to users on the Local Area Network but not responding to the Internet gateway/NAT router on 192.168.0.1.

     

    For virtual host websites, i.e. additional websites created via the Websites service in Server app, and also for the default "Server Website" and "Server Website (SSL)" well:

     

    The latter are controlled. "somewhat", by an httpd_server_app.conf file and you are meant to be able to include files for your personal settings although I have had trouble getting that to work (everything seems so sensitive for some reason).

     

    For the former, the generated virtual host files created by the Server app are stored in:

     

    /Library/Server/Web/Config/apache2/sites/

     

    I have tried including a file into my virtual host files in this location but everytime I do so all of the websites stop working. In Mountain Lion Server you are also recommended to use the webapp mechanism instead of modifying virtual host config files directly. And, like you I cannot find an example of how to do this and to do so in a manner which won't upset the Server app. Maybe the documentation needs expanding?

     

    I am surprised at this "adding another layer of work" when we should be able to safely include a file and for the thing to work.

     

    If you get an answer from someone who knows how to do the webapp thing with a simple example could you please let me know. Thanks

  • 2. Re: Managing Virtual Hosts on os X Server 10.7
    macmartin Level 2 Level 2 (495 points)

    Hello zzTontozz,

     

    no I didn't get any response.

     

    Somewhere I have read that one should add aditional conf files in the /etc/apache2/sites directory

    e.g.

    0001_any_80_[...].conf

    and include those in the 0000_any_80_[...].conf file.

    This works but only as long as you don´t open the webserver tab of Server.app because this results in rewriting the 0000_any_80_[...].conf files an droping the Include directives.

     

    I _do_ know how to manage apache but in OS X Server this becomes a real drag.

    It´s not only more complicated but it is also lousily documented in the manpages.

     

    Regards

    macmartin

  • 3. Re: Managing Virtual Hosts on os X Server 10.7
    zzTontozz Level 1 Level 1 (0 points)

    Unfortunately, this really feels like this is a bug. You should be able to edit the virtual host files in the /etc/apache2/sites directory. Let's hope an update comes out that fixes this.

     

    I guess for now it is better to leave those files alone.

  • 4. Re: Managing Virtual Hosts on os X Server 10.7
    zzTontozz Level 1 Level 1 (0 points)

    Hello again,

     

    I have been playing around with .htaccess files for virtual host sites on Mountain Lion Server. Note, Server app on Mountain Lion Server is different to Lion Server.

     

    I enabled "Allow overrides using .htaccess files" via the Mountain Lion Server Server app's Websites service and added a .htaccess file into the root directory of the virtual host under sites. Mountain Lion Server didn't get upset. I'm not sure what the performance hit will be by doing this but it's probably no big deal for sites that would use OSX server.