2013-08-28 00:27:01 +02:00
|
|
|
{# Define default values here so the template below can just focus on layout #}
|
|
|
|
{% set sitename = site.get('ServerName', id) %}
|
|
|
|
{% set vals = {
|
|
|
|
'interface': site.get('interface', '*'),
|
|
|
|
'port': site.get('port', '80'),
|
|
|
|
|
|
|
|
'ServerName': sitename,
|
|
|
|
'ServerAlias': site.get('ServerAlias', 'www.{0}'.format(sitename)),
|
|
|
|
|
|
|
|
'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)),
|
|
|
|
|
2013-11-05 20:32:49 +01:00
|
|
|
'DirectoryIndex': site.get('DirectoryIndex'),
|
|
|
|
'UseCanonicalName': site.get('UseCanonicalName'),
|
|
|
|
|
2013-08-28 00:27:01 +02:00
|
|
|
'LogLevel': site.get('LogLevel', 'warn'),
|
|
|
|
'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)),
|
2013-11-29 09:19:16 +01:00
|
|
|
'LogFormat': site.get('LogFormat', '"%h %l %u %t \\\"%r\\\" %>s %O"'),
|
2013-11-05 20:32:03 +01:00
|
|
|
'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)),
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
'DocumentRoot': site.get('DocumentRoot', '{0}/{1}'.format(map.wwwdir, sitename)),
|
2013-11-05 20:32:49 +01:00
|
|
|
'VirtualDocumentRoot': site.get('VirtualDocumentRoot'),
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
'Directory_default': '{0}/{1}'.format(map.wwwdir, sitename),
|
|
|
|
'Directory': {
|
|
|
|
'Options': '-Indexes FollowSymLinks',
|
|
|
|
'Order': 'allow,deny',
|
|
|
|
'Allow': 'from all',
|
|
|
|
'AllowOverride': 'None',
|
|
|
|
},
|
|
|
|
} %}
|
|
|
|
|
|
|
|
<VirtualHost {{ vals.interface }}:{{ vals.port }}>
|
|
|
|
ServerName {{ vals.ServerName }}
|
|
|
|
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
|
|
|
|
|
|
|
|
{% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
|
|
|
|
|
2013-11-05 20:32:49 +01:00
|
|
|
{% if site.get('DirectoryIndex') %}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %}
|
|
|
|
{% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
|
|
|
|
|
2013-08-28 00:27:01 +02:00
|
|
|
{% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %}
|
|
|
|
{% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %}
|
2013-11-29 09:19:16 +01:00
|
|
|
{% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
{% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %}
|
2013-11-05 20:32:49 +01:00
|
|
|
{% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
{% for path, dir in site.get('Directory', {}).items() %}
|
|
|
|
{% set dvals = {
|
|
|
|
'Options': dir.get('Options', vals.Directory.Options),
|
|
|
|
'Order': dir.get('Order', vals.Directory.Order),
|
2013-11-05 20:32:03 +01:00
|
|
|
'Allow': dir.get('Allow', vals.Directory.Allow),
|
|
|
|
'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride),
|
2013-08-28 00:27:01 +02:00
|
|
|
} %}
|
|
|
|
|
|
|
|
{% if path == 'default' %}{% set path = vals.Directory_default %}{% endif %}
|
|
|
|
|
|
|
|
<Directory "{{ path }}">
|
|
|
|
{% if dir.get('Options') != False %}Options {{ dvals.Options }}{% endif %}
|
|
|
|
{% if dir.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
|
|
|
|
{% if dir.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
|
|
|
|
{% if dir.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
|
|
|
|
|
|
|
|
{% if dir.get('Formula_Append') %}
|
|
|
|
{{ dir.Formula_Append|indent(8) }}
|
|
|
|
{% endif %}
|
|
|
|
</Directory>
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% if site.get('Formula_Append') %}
|
|
|
|
{{ site.Formula_Append|indent(4) }}
|
|
|
|
{% endif %}
|
|
|
|
</VirtualHost>
|