bundles/nginx: use metadata reactor to determine index files
This commit is contained in:
parent
3ee570a47a
commit
e2d8923dee
4 changed files with 30 additions and 6 deletions
|
@ -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;
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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': {
|
||||
|
|
Loading…
Reference in a new issue