From 8b9f0489c8cb412458376089a0b59aa30309325b Mon Sep 17 00:00:00 2001 From: John James Jacoby Date: Tue, 18 Jun 2024 07:32:11 -0500 Subject: [PATCH] Add custom.yaml support for WebSockets (#2385) Fixes #1956. --- management/web_update.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/management/web_update.py b/management/web_update.py index a0f0f799..c31fe8fc 100644 --- a/management/web_update.py +++ b/management/web_update.py @@ -166,6 +166,7 @@ def make_domain_config(domain, templates, ssl_certificates, env): pass_http_host_header = False proxy_redirect_off = False frame_options_header_sameorigin = False + web_sockets = False m = re.search("#(.*)$", url) if m: for flag in m.group(1).split(","): @@ -175,6 +176,8 @@ def make_domain_config(domain, templates, ssl_certificates, env): proxy_redirect_off = True elif flag == "frame-options-sameorigin": frame_options_header_sameorigin = True + elif flag == "web-sockets": + web_sockets = True url = re.sub("#(.*)$", "", url) nginx_conf_extra += "\tlocation %s {" % path @@ -185,6 +188,10 @@ def make_domain_config(domain, templates, ssl_certificates, env): nginx_conf_extra += "\n\t\tproxy_set_header Host $http_host;" if frame_options_header_sameorigin: nginx_conf_extra += "\n\t\tproxy_set_header X-Frame-Options SAMEORIGIN;" + if web_sockets: + nginx_conf_extra += "\n\t\tproxy_http_version 1.1;" + nginx_conf_extra += "\n\t\tproxy_set_header Upgrade $http_upgrade;" + nginx_conf_extra += "\n\t\tproxy_set_header Connection 'Upgrade';" nginx_conf_extra += "\n\t\tproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;" nginx_conf_extra += "\n\t\tproxy_set_header X-Forwarded-Host $http_host;" nginx_conf_extra += "\n\t\tproxy_set_header X-Forwarded-Proto $scheme;"