Skip to content

Commit

Permalink
Fix Apache Proxy Websockets (#1967)
Browse files Browse the repository at this point in the history
* fix: websockets for apache proxy

* fix: web socket protocol
  • Loading branch information
ALameLlama committed Apr 27, 2024
1 parent 21bd6f2 commit 7b209c3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scripts/site-types/apache-proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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?):\/\//ws:\/\//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/
"
Expand Down

0 comments on commit 7b209c3

Please sign in to comment.