allinurl / gwsocket

fast, standalone, language-agnostic WebSocket server RFC6455 compliant
http://gwsocket.io
MIT License
749 stars 67 forks source link

Using in multible domains on one port #26

Open tellustheguru opened 5 years ago

tellustheguru commented 5 years ago

As @ws-h-ono wrote on allinurl/goaccess issue #444

"Can you somehow try to share web socket ports against multiple sites? (Maybe by using URL path like, wss://ws.domain/site.domain ?)"

I like that Idea, even I have limited ports to spare.

imatasic commented 4 years ago

You can use reverse proxy to do that apache 2.4 +mod_proxy+ mod_proxy_wstunnel gwsocket running on port 8080

add this to Apache virtual host configuration:

servername ws.domain

        SSLProxyEngine on
    ProxyPass "/site1"  "wss://127.0.0.1:8080/"
        ProxyPassReverse "/site1"  "wss://127.0.0.1:8080/"
    ProxyPass "/site2"  "wss://127.0.0.1:8080/"
        ProxyPassReverse "/site2"  "wss://127.0.0.1:8080/"

you can then access the websocket server in javascript by var socket = new WebSocket('wss://ws.domain/site1'); var socket = new WebSocket('wss://ws.domain/site2');

etc...

allinurl commented 4 years ago

@imatasic Thanks for pointing that out!

tellustheguru commented 4 years ago

Hi @imatasic !

Could you send me a step by step instruction how to do this. I´m a newbie :)

What file do I put: var socket = new WebSocket('wss://ws.domain/site1'); etc ???