From 7ea85247e0f944973c3dd3ab9f15bd24c5b8aa22 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Tue, 22 Sep 2020 18:36:10 +0200 Subject: [PATCH] bundles/nginx: proxy is a dict now, add some more configuration options --- bundles/gitea/metadata.py | 4 +++- bundles/nginx/files/site_template | 16 +++++++++++++--- nodes/home/octoprint-vielschichtigkeit.py | 9 ++++++++- nodes/htz/ex42-1048908.py | 20 +++++++++++++++----- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/bundles/gitea/metadata.py b/bundles/gitea/metadata.py index 075bd44..5df732d 100644 --- a/bundles/gitea/metadata.py +++ b/bundles/gitea/metadata.py @@ -42,7 +42,9 @@ def nginx(metadata): 'vhosts': { metadata.get('gitea/domain'): { 'proxy': { - '/': 'http://127.0.0.1:22000', + '/': { + 'target': 'http://127.0.0.1:22000', + }, }, }, }, diff --git a/bundles/nginx/files/site_template b/bundles/nginx/files/site_template index fe740ee..902c16e 100644 --- a/bundles/nginx/files/site_template +++ b/bundles/nginx/files/site_template @@ -36,16 +36,26 @@ server { } % if proxy: -% for location, proxy_pass in proxy.items(): +% for location, options in proxy.items(): location ${location} { - proxy_pass ${proxy_pass}; + proxy_pass ${options['target']}; + proxy_http_version ${options.get('http_version', '1.1')}; proxy_set_header Host ${domain}; - proxy_set_header X-Script-Name /; +% if options.get('websockets', False): + proxy_set_header Connection "upgrade"; + proxy_set_header Upgrade $http_upgrade; +% endif proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; % if node.metadata['nginx']['use_ssl_for_all_connections']: proxy_set_header X-Forwarded-Proto HTTPS; % endif proxy_set_header X-Forwarded-Host ${domain}; +% for option, value in options.get('proxy_set_header', {}).items(): + proxy_set_header ${option} ${value}; +% endfor +% if location != '/': + proxy_set_header X-Script-Name ${location}; +% endif proxy_buffering off; } % endfor diff --git a/nodes/home/octoprint-vielschichtigkeit.py b/nodes/home/octoprint-vielschichtigkeit.py index 3471bf3..f4b7d26 100644 --- a/nodes/home/octoprint-vielschichtigkeit.py +++ b/nodes/home/octoprint-vielschichtigkeit.py @@ -19,8 +19,15 @@ nodes['home.octoprint-vielschichtigkeit'] = { 'use_ssl_for_all_connections': False, 'vhosts': { 'vielschichtigkeit.franzi-home.kunbox.net': { + 'do_not_set_content_security_headers': True, 'proxy': { - '/': 'http://[::1]:22030/', + '/': { + 'target': 'http://[::1]:22030/', + 'websockets': True, + 'proxy_set_header': { + 'X-Real-IP': '$remote_addr', + }, + }, }, }, }, diff --git a/nodes/htz/ex42-1048908.py b/nodes/htz/ex42-1048908.py index 22b3421..f6173ed 100644 --- a/nodes/htz/ex42-1048908.py +++ b/nodes/htz/ex42-1048908.py @@ -171,7 +171,9 @@ nodes['htz.ex42-1048908'] = { 'extras': True, 'do_not_set_content_security_headers': True, 'proxy': { - '/': 'http://127.0.0.1:8184', + '/': { + 'target': 'http://127.0.0.1:8184', + }, }, }, 'franzi.business': { @@ -180,7 +182,9 @@ nodes['htz.ex42-1048908'] = { }, 'jenkins.kunsmann.eu': { 'proxy': { - '/': 'http://localhost:22010/', + '/': { + 'target': 'http://localhost:22010/', + }, }, }, 'kunbox.net': {}, @@ -203,17 +207,23 @@ nodes['htz.ex42-1048908'] = { }, 'rspamd.mx0.kunbox.net': { 'proxy': { - '/': 'http://localhost:11334/', + '/': { + 'target': 'http://localhost:11334/', + }, }, }, 'rss.kunsmann.eu': { 'proxy': { - '/': 'http://localhost:8080/', + '/': { + 'target': 'http://localhost:8080/', + }, }, }, 'travelynx.franzi.business': { 'proxy': { - '/': 'http://127.0.0.1:22020', + '/': { + 'target': 'http://127.0.0.1:22020', + }, }, 'extras': True, },