{# 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 = { '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)), 'DirectoryIndex': site.get('DirectoryIndex'), '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)), 'DocumentRoot': site.get('DocumentRoot', '{0}/{1}'.format(map.wwwdir, sitename)), 'VirtualDocumentRoot': site.get('VirtualDocumentRoot'), 'Directory_default': '{0}/{1}'.format(map.wwwdir, sitename), 'Directory': { 'Options': '-Indexes +FollowSymLinks', 'Order': 'allow,deny', 'Allow': 'from all', 'Require': 'all granted', 'AllowOverride': 'None', }, 'Location': { 'Order': 'allow,deny', 'Allow': 'from all', 'Require': 'all granted', }, } %} ServerName {{ vals.ServerName }} {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %} {% if site.get('DirectoryIndex') %}DirectoryIndex {{ vals.DirectoryIndex }}{% 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 %} {% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %} {% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %} {% 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 %} {% for loc, path in site.get('Alias', {}).items() %} Alias {{ loc }} {{ path }} {% endfor %} {% for path, dir in site.get('Directory', {}).items() %} {% set dvals = { 'Options': dir.get('Options', vals.Directory.Options), 'Order': dir.get('Order', vals.Directory.Order), 'Allow': dir.get('Allow', vals.Directory.Allow), 'Require': dir.get('Require', vals.Directory.Require), 'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride), 'Dav': dir.get('Dav', False), } %} {% if path == 'default' %}{% set path = vals.Directory_default %}{% endif %} {% if dvals.get('Options') != False %}Options {{ dvals.Options }}{% endif %} {% if apache.use_require %} {% if dvals.get('Require') != False %}Require {{dvals.Require}}{% endif %} {% else %} {% if dvals.get('Order') != False %}Order {{ dvals.Order }}{% endif %} {% if dvals.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %} {% endif %} {% if dvals.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %} {% if dvals.get('Dav') != False %}Dav On{% endif %} {% if dir.get('Formula_Append') %} {{ dir.Formula_Append|indent(8) }} {% endif %} {% endfor %} {% for path, loc in site.get('Location', {}).items() %} {% set lvals = { '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), } %} {% if apache.use_require %} {% if lvals.get('Require') != False %}Require {{lvals.Require}}{% endif %} {% else %} {% if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %} {% if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %} {% endif %} {% if lvals.get('Dav') != False %}Dav On{% endif %} {% if loc.get('Formula_Append') %} {{ loc.Formula_Append|indent(8) }} {% endif %} {% endfor %} {% if site.get('Formula_Append') %} {{ site.Formula_Append|indent(4) }} {% endif %}