bundles/nginx: rename 'proxy' metadata to 'locations', support more generic options, move extras files to metadata
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-07-04 19:27:12 +02:00
parent a3a228fc2d
commit b5ab21549d
Signed by: kunsi
GPG key ID: 12E3D2136B818350
25 changed files with 164 additions and 144 deletions

View file

@ -32,8 +32,8 @@ server {
alias /var/www/dehydrated;
}
% if proxy:
% for location, options in proxy.items():
% if locations:
% for location, options in locations.items():
location ${location} {
proxy_pass ${options['target']};
proxy_http_version ${options.get('http_version', '1.1')};

View file

@ -58,7 +58,7 @@ def nginx(metadata):
'nginx': {
'vhosts': {
metadata.get('gitea/domain'): {
'proxy': {
'locations': {
'/': {
'target': 'http://127.0.0.1:22000',
},

View file

@ -47,7 +47,7 @@ def nginx(metadata):
'vhosts': {
'miniflux': {
'domain': metadata.get('miniflux/domain'),
'proxy': {
'locations': {
'/': {
'target': 'http://127.0.0.1:22040',
},

View file

@ -62,8 +62,6 @@ server {
% if max_body_size:
client_max_body_size ${max_body_size};
% elif proxy or php:
client_max_body_size 5M;
% endif
% if not do_not_set_content_security_headers:
@ -86,40 +84,61 @@ server {
}
% endif
% if proxy:
% for location, options in proxy.items():
% if locations:
% for location, options in sorted(locations.items()):
location ${location} {
% if 'target' in options:
proxy_pass ${options['target']};
proxy_http_version ${options.get('http_version', '1.1')};
proxy_set_header Host ${domain};
% if options.get('websockets', False):
% if options.get('websockets', False):
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
% endif
% endif
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
% if ssl:
% if ssl:
proxy_set_header X-Forwarded-Proto HTTPS;
% endif
% endif
proxy_set_header X-Forwarded-Host ${domain};
% for option, value in options.get('proxy_set_header', {}).items():
% for option, value in options.get('proxy_set_header', {}).items():
proxy_set_header ${option} ${value};
% endfor
% if location != '/':
% endfor
% if location != '/':
proxy_set_header X-Script-Name ${location};
% endif
% endif
proxy_buffering off;
client_max_body_size ${options.get('max_body_size', '5M')};
% elif 'redirect' in options:
return ${options.get('mode', 302)} ${options['redirect']};
% elif 'return' in options:
return ${options.get('mode', 200)} '${options['return']}';
% elif 'root' in options:
root ${options['root']};
% elif 'alias' in options:
alias ${options['alias']};
% endif
% if 'auth' in options:
auth_basic "${options['auth'].get('realm', vhost)}";
auth_basic_user_file ${options['auth']['file']};
% endif
% for opt in sorted(options.get('additional_config', set())):
${opt};
% endfor
}
% endfor
% endif
% endfor
% endif
% if php:
location ~ \.php$ {
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php${php_version}-fpm.sock;
}
% endif
% if not max_body_size:
client_max_body_size 5M;
% endif
% endif
% if extras:
<%include file="extras/${node.name}/${vhost}" />
% endif

View file

@ -45,7 +45,7 @@ def nginx(metadata):
'vhosts': {
'pleroma': {
'domain': metadata.get('pleroma/url'),
'proxy': {
'locations': {
'/': {
'target': 'http://127.0.0.1:21000',
'websockets': True,