2015-02-15 00:06:44 +01:00
|
|
|
{# Define default values here so the template below can just focus on layout #}
|
|
|
|
{% from "apache/map.jinja" import apache with context %}
|
|
|
|
{% set sitename = site.get('ServerName', id) %}
|
|
|
|
|
|
|
|
{% set vals = {
|
2016-01-25 12:19:55 +01:00
|
|
|
'interfaces': site.get('interface', '*').split(),
|
2015-02-15 00:06:44 +01:00
|
|
|
'port': site.get('port', '80'),
|
|
|
|
|
|
|
|
'ServerName': sitename,
|
|
|
|
'ServerAlias': site.get('ServerAlias', 'www.{0}'.format(sitename)),
|
|
|
|
|
|
|
|
'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)),
|
|
|
|
|
|
|
|
'UseCanonicalName': site.get('UseCanonicalName'),
|
|
|
|
|
|
|
|
'LogLevel': site.get('LogLevel', 'warn'),
|
|
|
|
'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)),
|
|
|
|
'LogFormat': site.get('LogFormat', '"%h %l %u %t \\\"%r\\\" %>s %O"'),
|
|
|
|
'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)),
|
|
|
|
|
|
|
|
'ProxyPreserveHost': site.get('ProxyPreserveHost', 'On'),
|
2015-03-11 18:28:11 +01:00
|
|
|
'ProxyRoute': site.get('ProxyRoute', {}),
|
2015-02-15 00:06:44 +01:00
|
|
|
} %}
|
|
|
|
|
2016-01-25 12:19:55 +01:00
|
|
|
<VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}>
|
2015-02-15 00:06:44 +01:00
|
|
|
ServerName {{ vals.ServerName }}
|
|
|
|
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
|
|
|
|
|
|
|
|
{% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
|
|
|
|
|
|
|
|
{% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
|
|
|
|
|
|
|
|
{% 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 %}
|
|
|
|
|
2015-06-09 11:48:35 +02:00
|
|
|
{% if site.get('SSLCertificateFile') %}
|
|
|
|
SSLEngine on
|
|
|
|
SSLCertificateFile {{ site.SSLCertificateFile }}
|
|
|
|
{% if site.get('SSLCertificateKeyFile') %}
|
|
|
|
SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}
|
|
|
|
{% endif %}
|
|
|
|
{% if site.get('SSLCertificateChainFile') %}
|
|
|
|
SSLCertificateChainFile {{ site.SSLCertificateChainFile}}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
|
2015-03-11 18:28:11 +01:00
|
|
|
ProxyPreserveHost {{ vals.ProxyPreserveHost }}
|
2015-03-25 14:48:13 +01:00
|
|
|
{% for proxy, proxyargs in vals.ProxyRoute|dictsort|reverse %}
|
2015-03-11 18:28:11 +01:00
|
|
|
{% set proxyvals = {
|
|
|
|
'ProxyPassSource': proxyargs.get('ProxyPassSource', '/'),
|
|
|
|
'ProxyPassTarget': proxyargs.get('ProxyPassTarget', 'https://{0}'.format(sitename)),
|
2016-05-23 19:32:12 +02:00
|
|
|
'ProxyPassTargetOptions': proxyargs.get('ProxyPassTargetOptions', ''),
|
2015-03-11 18:28:11 +01:00
|
|
|
'ProxyPassReverseSource': proxyargs.get('ProxyPassReverseSource', '/'),
|
|
|
|
'ProxyPassReverseTarget': proxyargs.get('ProxyPassReverseTarget', site.get('ProxyPassTarget', 'https://{0}'.format(sitename))),
|
|
|
|
} %}
|
|
|
|
######### {{proxy}} #########
|
2016-05-23 19:32:12 +02:00
|
|
|
ProxyPass {{ proxyvals.ProxyPassSource }} {{ proxyvals.ProxyPassTarget }} {{ proxyvals.ProxyPassTargetOptions }}
|
2015-03-11 18:28:11 +01:00
|
|
|
ProxyPassReverse {{ proxyvals.ProxyPassReverseSource }} {{ proxyvals.ProxyPassReverseTarget }}
|
|
|
|
{% endfor %}
|
2015-02-15 00:06:44 +01:00
|
|
|
{% if site.get('Formula_Append') %}
|
|
|
|
{{ site.Formula_Append|indent(4) }}
|
|
|
|
{% endif %}
|
|
|
|
</VirtualHost>
|