diff --git a/bundles/nginx/files/site_template b/bundles/nginx/files/site_template index 902c16e..c38e9b7 100644 --- a/bundles/nginx/files/site_template +++ b/bundles/nginx/files/site_template @@ -1,7 +1,7 @@ server { server_name ${domain}; - root ${webroot if webroot else '/var/www/{}/'.format(domain)}; - index ${index if index else 'index.html index.htm'}; + root ${webroot if webroot else '/var/www/{}/'.format(vhost)}; + index ${' '.join(index)}; % if node.metadata['nginx']['use_ssl_for_all_connections']: listen 443 ssl http2; diff --git a/bundles/nginx/items.py b/bundles/nginx/items.py index 193092c..fd95d5c 100644 --- a/bundles/nginx/items.py +++ b/bundles/nginx/items.py @@ -58,7 +58,10 @@ for vhost, config in node.metadata.get('nginx', {}).get('vhosts', {}).items(): files['/etc/nginx/sites/{}'.format(vhost)] = { 'source': 'site_template', 'content_type': 'mako', - 'context': config, + 'context': { + 'vhost': vhost, + **config, + }, 'needs': set(), 'triggers': { 'svc_systemd:nginx:restart', diff --git a/bundles/nginx/metadata.py b/bundles/nginx/metadata.py index 4718a7e..5e0c259 100644 --- a/bundles/nginx/metadata.py +++ b/bundles/nginx/metadata.py @@ -46,3 +46,27 @@ def letsencrypt(metadata): }, }, } + + +@metadata_reactor +def index_files(metadata): + vhosts = {} + + for vhost, config in metadata.get('nginx/vhosts', {}).items(): + vhosts[vhost] = { + 'index': [ + 'index.html', + 'index.htm', + ], + } + + if config.get('php', False): + # If we're using PHP, make sure index.php is tried first + vhosts[vhost]['index'].insert(0, 'index.php') + + + return { + 'nginx': { + 'vhosts': vhosts, + }, + } diff --git a/nodes/htz/ex42-1048908.py b/nodes/htz/ex42-1048908.py index b8d1543..d9f5700 100644 --- a/nodes/htz/ex42-1048908.py +++ b/nodes/htz/ex42-1048908.py @@ -192,7 +192,6 @@ nodes['htz.ex42-1048908'] = { }, 'postfixadmin.mx0.kunbox.net': { 'webroot': '/srv/postfixadmin/public/', - 'index': 'index.php', 'php': True, # FIXME this assumes php 7.3 is installed and configured already }, 'rspamd.mx0.kunbox.net': { @@ -217,11 +216,9 @@ nodes['htz.ex42-1048908'] = { }, }, 'webmail.mx0.kunbox.net': { - 'index': 'index.php', 'php': True, }, 'wiki.franzi.business': { - 'index': 'doku.php', 'extras': True, 'php': True, 'webroot_config': {