Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 7b209c3

Browse files
authored
Fix Apache Proxy Websockets (#1967)
* fix: websockets for apache proxy * fix: web socket protocol
1 parent 21bd6f2 commit 7b209c3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

scripts/site-types/apache-proxy.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,35 @@ if [ -n "$2" ]
2323
then
2424
if ! [[ "$2" =~ ^[0-9]+$ ]]
2525
then
26+
if ! [[ "$2" =~ ^https: ]]
27+
then
28+
socket=$(echo "$2" | sed -E "s/^http(s?):\/\//ws:\/\//g")
29+
else
30+
socket=$(echo "$2" | sed -E "s/^http(s?):\/\//wss:\/\//g")
31+
fi
32+
2633
proxyPass="
34+
RewriteEngine On
35+
RewriteCond %{HTTP:Upgrade} =websocket [NC]
36+
RewriteRule /(.*) $socket/ [P,L]
37+
2738
ProxyPass / ${2}/
2839
ProxyPassReverse / ${2}/
2940
"
3041
else proxyPass="
42+
RewriteEngine On
43+
RewriteCond %{HTTP:Upgrade} =websocket [NC]
44+
RewriteRule /(.*) ws://127.0.0.1:$2/ [P,L]
45+
3146
ProxyPass / http://127.0.0.1:$2/
3247
ProxyPassReverse / http://127.0.0.1:$2/
3348
"
3449
fi
3550
else proxyPass="
51+
RewriteEngine On
52+
RewriteCond %{HTTP:Upgrade} =websocket [NC]
53+
RewriteRule /(.*) ws://127.0.0.1/ [P,L]
54+
3655
ProxyPass / http://127.0.0.1/
3756
ProxyPassReverse / http://127.0.0.1/
3857
"

0 commit comments

Comments
 (0)