crowbar/crowbar-core

View on GitHub
chef/cookbooks/provisioner/templates/default/base-apache.conf.erb

Summary

Maintainability
Test Coverage
# Strictly, Listen and NameVirtualHost should be set by modifying the
# [:apache][:listen_ports] attribute in the setup_base_images recipe, but that
# would somehow require rewriting ports.conf (listen.conf on SUSE), so we'd
# need to either set that attribute *before* including the apache2 recipe
# (in which case the provisioner port will be the *only* port apache listens
# on, preventing using apache for any other purpose), or we need to rewrite
# ports.conf to include whatever's already there *plus* the provisioner
# port.  The latter is the best behaved, but frankly strikes me as messy.
# So until I come up with something better, here we go:
Listen <%= @admin_ip %>:<%=@port%>
<%- if node[:apache][:version].to_f < 2.4 %>
NameVirtualHost *:<%=@port%>
<%- end %>

<VirtualHost *:<%=@port%>>

    DocumentRoot <%= @docroot %>
    ErrorLog <%= @errorlog %>
    CustomLog <%= @logfile %> combined

    HostnameLookups Off
    UseCanonicalName Off

    <Directory />
        Options None
        AllowOverride None
        <%- if node[:apache][:version].to_f < 2.4 %>
        Order deny,allow
        Deny from all
        <%- else %>
        Require all denied
        <%- end %>
    </Directory>

    <Directory <%= @docroot %>/>
        Options Indexes FollowSymLinks
        AllowOverride None
        <%- if node[:apache][:version].to_f < 2.4 %>
        Order allow,deny
        Allow from <%= @admin_subnet %>/<%= @admin_netmask %>
        <%- else %>
        Require ip <%= @admin_subnet %>/<%= @admin_netmask %>
        <%- end %>
    </Directory>

</VirtualHost>