2018-02-04 14:13:18 +01:00
|
|
|
#
|
|
|
|
# This file is managed by Salt! Do not edit by hand!
|
|
|
|
#
|
2015-02-15 00:06:44 +01:00
|
|
|
{# Define default values here so the template below can just focus on layout #}
|
|
|
|
{% 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,
|
2018-01-31 00:20:25 +01:00
|
|
|
'ServerAlias': site.get('ServerAlias', ''),
|
2015-02-15 00:06:44 +01:00
|
|
|
|
|
|
|
'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)),
|
2020-10-14 02:57:00 +02:00
|
|
|
'LogFormat': site.get('LogFormat', '"%a %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\""'),
|
2018-01-05 00:59:57 +01:00
|
|
|
'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)),
|
2017-03-09 12:44:32 +01:00
|
|
|
|
2016-05-24 19:10:01 +02:00
|
|
|
'ProxyRequests': site.get('ProxyRequests', 'Off'),
|
2015-02-15 00:06:44 +01:00
|
|
|
'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
|
|
|
|
2017-03-09 12:44:32 +01:00
|
|
|
'Location': {
|
|
|
|
'Order': 'allow,deny',
|
|
|
|
'Allow': 'from all',
|
|
|
|
'Require': 'all granted',
|
|
|
|
},
|
|
|
|
'LocationMatch': {
|
|
|
|
'Order': 'allow,deny',
|
|
|
|
'Allow': 'from all',
|
|
|
|
'Require': 'all granted',
|
|
|
|
},
|
|
|
|
} %}
|
2020-09-13 06:07:20 +02: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 %}
|
2018-01-05 01:30:42 +01:00
|
|
|
{% if site.get('LogFormat') != False -%}LogFormat {{ vals.LogFormat }}{% endif %}
|
|
|
|
{% if site.get('CustomLog') != False -%}LogFormat {{ vals.LogFormat }} {{ sitename }}
|
|
|
|
CustomLog {{ vals.CustomLog }} {{ sitename }}{% endif %}
|
2015-02-15 00:06:44 +01:00
|
|
|
|
2017-03-09 12:44:32 +01:00
|
|
|
{% if site.get('SSLCertificateFile') %}SSLEngine on
|
2015-06-09 11:48:35 +02:00
|
|
|
SSLCertificateFile {{ site.SSLCertificateFile }}
|
2017-03-09 12:44:32 +01:00
|
|
|
{% if site.get('SSLCertificateKeyFile') %}SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}{% endif %}
|
2019-10-17 09:12:54 +02:00
|
|
|
{% if site.get('SSLCertificateChainFile') %}SSLCertificateChainFile {{ site.SSLCertificateChainFile }}{% endif %}
|
2015-06-09 11:48:35 +02:00
|
|
|
{% endif %}
|
2017-03-09 12:44:32 +01:00
|
|
|
{% if site.get('Rewrite') %}RewriteEngine on
|
|
|
|
{{ site.Rewrite }}
|
|
|
|
{% endif %}
|
|
|
|
{% if site.get('SSLProxyEngine') %}SSLProxyEngine {{ site.SSLProxyEngine }}{% endif %}
|
2016-05-24 19:10:01 +02:00
|
|
|
ProxyRequests {{ vals.ProxyRequests }}
|
2017-03-09 12:44:32 +01:00
|
|
|
ProxyPreserveHost {{ vals.ProxyPreserveHost }}
|
|
|
|
{% if site.get('ProxyErrorOverride') %}ProxyErrorOverride {{ site.ProxyErrorOverride }} {% endif %}
|
|
|
|
{% if site.get('ProxyErrorDir') %}ProxyPass /{{ site.ProxyErrorDir }}/ ! {% endif %}
|
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', '/'),
|
2016-08-03 06:29:53 +02:00
|
|
|
'ProxyPassReverseTarget': proxyargs.get('ProxyPassReverseTarget', proxyargs.get('ProxyPassTarget', 'https://{0}'.format(sitename))),
|
2015-03-11 18:28:11 +01:00
|
|
|
} %}
|
|
|
|
######### {{proxy}} #########
|
2017-03-09 12:44:32 +01:00
|
|
|
ProxyPass {{ proxyvals.ProxyPassSource }} {{ proxyvals.ProxyPassTarget }} {{ proxyvals.ProxyPassTargetOptions }}
|
|
|
|
ProxyPassReverse {{ proxyvals.ProxyPassReverseSource }} {{ proxyvals.ProxyPassReverseTarget }}
|
|
|
|
{% endfor %}
|
|
|
|
|
2020-09-13 06:07:20 +02:00
|
|
|
{% for path, loc in site.get('Location', {}).items() %}
|
|
|
|
{% set lvals = {
|
2017-03-09 12:44:32 +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-08-02 01:00:36 +02:00
|
|
|
{% if apache.version == '2.4' %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% if lvals.get('Require') != False %}Require {{ lvals.Require }}{% endif %}
|
2017-03-09 12:44:32 +01:00
|
|
|
{% else %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %}
|
|
|
|
{% if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %}
|
2017-03-09 12:44:32 +01:00
|
|
|
{% endif %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% if loc.get('Formula_Append') %} {{ loc.Formula_Append|indent(8) }} {% endif %}
|
2017-03-09 12:44:32 +01:00
|
|
|
</Location>
|
|
|
|
{% endfor %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% for regpath, locmat in site.get('LocationMatch', {}).items() %}
|
|
|
|
{% set lmvals = {
|
2017-03-09 12:44:32 +01:00
|
|
|
'Order': locmat.get('Order', vals.LocationMatch.Order),
|
|
|
|
'Allow': locmat.get('Allow', vals.LocationMatch.Allow),
|
|
|
|
'Require': locmat.get('Require', vals.LocationMatch.Require),
|
|
|
|
'Dav': locmat.get('Dav', False),
|
|
|
|
} %}
|
|
|
|
<LocationMatch "{{ regpath }}">
|
2017-08-02 01:00:36 +02:00
|
|
|
{% if apache.version == '2.4' %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% if lmvals.get('Require') != False %}Require {{ lmvals.Require }}{% endif %}
|
2017-03-09 12:44:32 +01:00
|
|
|
{% else %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% if lmvals.get('Order') != False %}Order {{ lmvals.Order }}{% endif %}
|
|
|
|
{% if lmvals.get('Allow') != False %}Allow {{ lmvals.Allow }}{% endif %}
|
2017-03-09 12:44:32 +01:00
|
|
|
{% endif %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% if locmat.get('Formula_Append') %} {{ locmat.Formula_Append|indent(8) }} {% endif %}
|
2017-03-09 12:44:32 +01:00
|
|
|
</LocationMatch>
|
2015-03-11 18:28:11 +01:00
|
|
|
{% endfor %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% for proxypath, prox in site.get('Proxy_control', {}).items() %}
|
|
|
|
{% set proxvals = {
|
2017-03-09 12:44:32 +01:00
|
|
|
'AllowAll': prox.get('AllowAll', vals.AllowAll),
|
|
|
|
'AllowCountry': prox.get('AllowCountry', vals.AllowCountry),
|
|
|
|
'AllowIP': prox.get('AllowIP', vals.AllowIP),
|
|
|
|
} %}
|
|
|
|
<Proxy "{{ proxypath }}">
|
2020-09-13 06:07:20 +02:00
|
|
|
{% if proxvals.get('AllowAll') != False %}
|
2017-03-09 12:44:32 +01:00
|
|
|
Require all granted
|
2020-09-13 06:07:20 +02:00
|
|
|
{% else %}
|
2017-03-09 12:44:32 +01:00
|
|
|
{% if proxvals.get('AllowCountry') != False %}{% set country_list = proxvals.get('AllowCountry', {}) %}GeoIPEnable On
|
|
|
|
{% for every_country in country_list %}SetEnvIf GEOIP_COUNTRY_CODE {{ every_country }} AllowCountry
|
|
|
|
{% endfor %}Require env AllowCountry {% endif %}
|
|
|
|
{% if proxvals.get('AllowIP') is defined %} {% set ip_list = proxvals.get('AllowIP', {}) %}
|
|
|
|
Require ip {% for every_ip in ip_list %}{{ every_ip }} {% endfor %} {% endif %}
|
2020-09-13 06:07:20 +02:00
|
|
|
{% endif %}
|
2017-03-09 12:44:32 +01:00
|
|
|
</Proxy>
|
2020-09-13 06:07:20 +02:00
|
|
|
{% endfor %}
|
2015-02-15 00:06:44 +01:00
|
|
|
{% if site.get('Formula_Append') %}
|
|
|
|
{{ site.Formula_Append|indent(4) }}
|
|
|
|
{% endif %}
|
|
|
|
</VirtualHost>
|