2013-08-28 00:27:01 +02:00
|
|
|
{# Define default values here so the template below can just focus on layout #}
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- set sitename = site.get('ServerName', id) -%}
|
2014-10-01 10:35:53 +02:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- set vals = {
|
2016-01-25 12:19:55 +01:00
|
|
|
'interfaces': site.get('interface', '*').split(),
|
2013-08-28 00:27:01 +02:00
|
|
|
'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'),
|
2016-01-31 23:35:29 +01:00
|
|
|
'AllowEncodedSlashes': site.get('AllowEncodedSlashes', 'Off'),
|
2013-11-05 20:32:49 +01:00
|
|
|
|
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)),
|
2017-03-20 15:10:37 +01:00
|
|
|
'LogFormat': site.get('LogFormat', '"%h %l %u %t \\\"%r\\\" %>s"'),
|
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
|
|
|
|
2016-02-16 11:53:49 +01:00
|
|
|
'Timeout': site.get('Timeout'),
|
|
|
|
'LimitRequestFields': site.get('LimitRequestFields'),
|
|
|
|
|
2013-08-28 00:27:01 +02:00
|
|
|
'Directory_default': '{0}/{1}'.format(map.wwwdir, sitename),
|
|
|
|
'Directory': {
|
2014-10-28 18:50:04 +01:00
|
|
|
'Options': '-Indexes +FollowSymLinks',
|
2013-08-28 00:27:01 +02:00
|
|
|
'Order': 'allow,deny',
|
|
|
|
'Allow': 'from all',
|
2014-10-28 15:13:13 +01:00
|
|
|
'Require': 'all granted',
|
2013-08-28 00:27:01 +02:00
|
|
|
'AllowOverride': 'None',
|
|
|
|
},
|
2015-12-09 06:48:08 +01:00
|
|
|
'Location': {
|
|
|
|
'Order': 'allow,deny',
|
|
|
|
'Allow': 'from all',
|
|
|
|
'Require': 'all granted',
|
|
|
|
},
|
2016-01-31 23:35:29 +01:00
|
|
|
} -%}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
<VirtualHost {% for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}>
|
2013-08-28 00:27:01 +02:00
|
|
|
ServerName {{ vals.ServerName }}
|
|
|
|
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
|
|
|
|
|
2016-04-10 22:17:44 +02:00
|
|
|
{% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{% if site.get('DirectoryIndex') -%}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %}
|
|
|
|
{% if site.get('UseCanonicalName') -%}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
|
|
|
|
{% if site.get('AllowEncodedSlashes') != False -%}AllowEncodedSlashes {{ vals.AllowEncodedSlashes }}{% endif %}
|
2013-11-05 20:32:49 +01:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{% if site.get('LogLevel') != False -%}LogLevel {{ vals.LogLevel }}{% endif %}
|
|
|
|
{% if site.get('ErrorLog') != False -%}ErrorLog {{ vals.ErrorLog }}{% endif %}
|
|
|
|
{% if site.get('CustomLog') != False -%}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{% if site.get('DocumentRoot') != False -%}DocumentRoot {{ vals.DocumentRoot }}{% endif %}
|
|
|
|
{% if site.get('VirtualDocumentRoot') -%}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
2017-02-01 23:39:29 +01:00
|
|
|
{% if site.get('Timeout') != False and site.get('Timeout') != None %}Timeout {{ vals.Timeout }}{% endif %}
|
2016-02-16 11:53:49 +01:00
|
|
|
{% if site.get('LimitRequestFields') %}LimitRequestFields {{ vals.LimitRequestFields }}{% endif %}
|
|
|
|
|
2017-03-09 12:44:32 +01:00
|
|
|
{% if site.get('SSLCertificateFile') %}SSLEngine on
|
2015-04-02 14:23:21 +02:00
|
|
|
SSLCertificateFile {{ site.SSLCertificateFile }}
|
2017-03-09 12:44:32 +01:00
|
|
|
{% if site.get('SSLCertificateKeyFile') %}SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}{% endif %}
|
|
|
|
{% if site.get('SSLCertificateChainFile') %}SSLCertificateChainFile {{ site.SSLCertificateChainFile}}{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if site.get('Rewrite') %}RewriteEngine on
|
|
|
|
{{ site.Rewrite }}
|
|
|
|
{% endif %}
|
2015-04-02 14:23:21 +02:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- for loc, path in site.get('Alias', {}).items() %}
|
2015-12-09 06:48:08 +01:00
|
|
|
Alias {{ loc }} {{ path }}
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- endfor %}
|
2015-12-09 06:48:08 +01:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- for path, dir in site.get('Directory', {}).items() -%}
|
|
|
|
{%- set dvals = {
|
2013-08-28 00:27:01 +02:00
|
|
|
'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),
|
2014-10-01 10:35:53 +02:00
|
|
|
'Require': dir.get('Require', vals.Directory.Require),
|
2013-11-05 20:32:03 +01:00
|
|
|
'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride),
|
2015-12-09 06:48:08 +01:00
|
|
|
'Dav': dir.get('Dav', False),
|
2013-08-28 00:27:01 +02:00
|
|
|
} %}
|
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- if path == 'default' %}{% set path = vals.Directory_default %}{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
<Directory "{{ path }}">
|
2015-12-09 06:48:08 +01:00
|
|
|
{% if dvals.get('Options') != False %}Options {{ dvals.Options }}{% endif %}
|
2017-03-20 16:57:47 +01:00
|
|
|
{% if map.use_require %}
|
2015-12-09 06:48:08 +01:00
|
|
|
{% if dvals.get('Require') != False %}Require {{dvals.Require}}{% endif %}
|
2014-10-28 15:13:13 +01:00
|
|
|
{% else %}
|
2015-12-09 06:48:08 +01:00
|
|
|
{% if dvals.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
|
|
|
|
{% if dvals.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
|
2014-10-28 15:13:13 +01:00
|
|
|
{% endif %}
|
2015-12-09 06:48:08 +01:00
|
|
|
{% if dvals.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
|
|
|
|
{% if dvals.get('Dav') != False %}Dav On{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
{% if dir.get('Formula_Append') %}
|
|
|
|
{{ dir.Formula_Append|indent(8) }}
|
|
|
|
{% endif %}
|
|
|
|
</Directory>
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- endfor %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- for path, loc in site.get('Location', {}).items() %}
|
|
|
|
{%- set lvals = {
|
2015-12-09 06:48:08 +01:00
|
|
|
'Order': loc.get('Order', vals.Location.Order),
|
|
|
|
'Allow': loc.get('Allow', vals.Location.Allow),
|
|
|
|
'Require': loc.get('Require', vals.Location.Require),
|
|
|
|
'Dav': loc.get('Dav', False),
|
|
|
|
} %}
|
|
|
|
|
|
|
|
<Location "{{ path }}">
|
2017-03-20 16:57:47 +01:00
|
|
|
{% if map.use_require %}
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- if lvals.get('Require') != False %}Require {{lvals.Require}}{% endif %}
|
2015-12-09 06:48:08 +01:00
|
|
|
{% else %}
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %}
|
|
|
|
{%- if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %}
|
2015-12-09 06:48:08 +01:00
|
|
|
{% endif %}
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- if lvals.get('Dav') != False %}Dav On{% endif %}
|
2015-12-09 06:48:08 +01:00
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- if loc.get('Formula_Append') %}
|
2015-12-09 06:48:08 +01:00
|
|
|
{{ loc.Formula_Append|indent(8) }}
|
|
|
|
{% endif %}
|
|
|
|
</Location>
|
|
|
|
{% endfor %}
|
|
|
|
|
2016-01-31 23:35:29 +01:00
|
|
|
{%- if site.get('Formula_Append') %}
|
2013-08-28 00:27:01 +02:00
|
|
|
{{ site.Formula_Append|indent(4) }}
|
|
|
|
{% endif %}
|
|
|
|
</VirtualHost>
|