From c3961ab7fd55837c4f1025d701f10264964c78d7 Mon Sep 17 00:00:00 2001 From: Nicholas Ciechanowski Date: Thu, 18 Apr 2024 09:33:38 +1000 Subject: [PATCH 1/2] fix: websockets for apache proxy --- scripts/site-types/apache-proxy.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/site-types/apache-proxy.sh b/scripts/site-types/apache-proxy.sh index c4016c53e..e9bcbc671 100644 --- a/scripts/site-types/apache-proxy.sh +++ b/scripts/site-types/apache-proxy.sh @@ -23,16 +23,35 @@ if [ -n "$2" ] then if ! [[ "$2" =~ ^[0-9]+$ ]] then + if ! [[ "$2" =~ ^https: ]] + then + socket=$(echo "$2" | sed -E "s/^http(s?):\/\//wss:\/\//g") + else + socket=$(echo "$2" | sed -E "s/^http(s?):\/\//wss:\/\//g") + fi + proxyPass=" + RewriteEngine On + RewriteCond %{HTTP:Upgrade} =websocket [NC] + RewriteRule /(.*) $socket/ [P,L] + ProxyPass / ${2}/ ProxyPassReverse / ${2}/ " else proxyPass=" + RewriteEngine On + RewriteCond %{HTTP:Upgrade} =websocket [NC] + RewriteRule /(.*) ws://127.0.0.1:$2/ [P,L] + ProxyPass / http://127.0.0.1:$2/ ProxyPassReverse / http://127.0.0.1:$2/ " fi else proxyPass=" +RewriteEngine On +RewriteCond %{HTTP:Upgrade} =websocket [NC] +RewriteRule /(.*) ws://127.0.0.1/ [P,L] + ProxyPass / http://127.0.0.1/ ProxyPassReverse / http://127.0.0.1/ " From 7c5ea6ecb039f542bbd7490f1724bd91da643506 Mon Sep 17 00:00:00 2001 From: Nicholas Ciechanowski Date: Fri, 19 Apr 2024 11:35:06 +1000 Subject: [PATCH 2/2] fix: web socket protocol --- scripts/site-types/apache-proxy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/site-types/apache-proxy.sh b/scripts/site-types/apache-proxy.sh index e9bcbc671..0e04d793b 100644 --- a/scripts/site-types/apache-proxy.sh +++ b/scripts/site-types/apache-proxy.sh @@ -25,7 +25,7 @@ then then if ! [[ "$2" =~ ^https: ]] then - socket=$(echo "$2" | sed -E "s/^http(s?):\/\//wss:\/\//g") + socket=$(echo "$2" | sed -E "s/^http(s?):\/\//ws:\/\//g") else socket=$(echo "$2" | sed -E "s/^http(s?):\/\//wss:\/\//g") fi