How to pass through two websockets to a SPA using root

Help @Whitestrake :blush:

What I have is a spa (https://quasar-framework.org/guide/app-deploying-spa.html)

But that SPA has two websocket clients (one a socketio one, one an extension of native socket client)
All this works fine in my dev server.

So in caddy I have this which serves the SPA fine but not too surprisingly? the connections to the two websocket servers fail (timeout). I’ve confirmed that the socketio socket is getting the right url so I can only assume it’s cause I need some “websocket passthrough” from caddy?

# Lightinging System Frontend
https://lights2.XXXXX.net {
         import wildcard_cert
         root /mnt/data/lights-frontend
         }

My SPA doesn’t use a url proxy (like /api) so scratching my head here cause using the proxy directive and websocket or transparent preset doesn’t apply?? I did try one so but that just results in a 502 bad gateway (really no surprise)

https://lights2.kebler.net {
         import wildcard_cert
         root /mnt/data/lights-frontend
        proxy / ws://192.168.0.231:3030 {
	     websocket
        }
         }

After some investigation I’m guessing it might have nothing to do with Caddy but has to do with mixing https with non-tls sockets. So unless someone has some other cleaver way using caddy to mix these I’ll either have to not use caddy to serve or upgrade my socket servers to tls.

Hi @dkebler!

Gotta admit, I don’t think I’m quite familiar enough with this one to make any recommendations.

I can say it wouldn’t be TLS / non-TLS issues if you’re getting timeouts (TLS errors aren’t handled by dropping the traffic).

If it’s got the right URL, are the sockets coming in on different ports, maybe? Possibly getting firewalled?

The second Caddyfile example has a proxy to port 3030 on an internal network, should that be exposed internally? Is the SPA instance on the client trying to connect to 3030?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.