Tuesday, May 18, 2021

[How To] Apache Websockets WSS in a Subfolder

 The following syntax can be used to run websocket connections in Apache in a subfolder : 

# /websocket1 to port 2085

RewriteCond %{REQUEST_URI} /websocket1 [NC]

RewriteCond %{HTTP:Upgrade} "(?i)websocket" [NC,OR]

RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]

RewriteRule ^/(.*)$ ws://127.0.0.1:2085/$1 [P,QSA,L]


# /websocket2 to port 3126

RewriteCond %{REQUEST_URI} /websocket2 [NC]

RewriteCond %{HTTP:Upgrade} "(?i)websocket" [NC,OR]

RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]

RewriteRule ^/(.*)$ ws://127.0.0.1:3126/$1 [P,QSA,L]

The above need to be used in a SSL virtualhost.

For a non-SSL virtualhost, one can simply use:

ProxyPass "/websocket1" "ws://127.0.0.1:2085/"
ProxyPass "/websocket2" "ws://127.0.0.1:3126/"

No comments:

Post a Comment

How to set up Kodi with YouTube addon on Raspberry OS Debian 12

 In this post, we review how to run Kodi with Kodi Youtube Addon on Raspberry Pi 5.  There are two versions of Kodi available on Raspberry P...