Websocket Proxying doesn't seem to work


(Hansen) #1

I’m trying to proxy a websocket-only server like an HTTPS proxy.
I have tried…

subdomain.domain.tld{
proxy / (http://)localhost:3000 {
websocket (tried without the flag as well)
}
tls {
	dns provide
  wildcard
 }
}

Doesn’t include any error or log details.


(Matthew Fay) #2

If you’re trying to use websockets on your localhost:3000 proxy, you don’t want the websocket directive; that’s a separate feature from the proxy. The websocket directive takes either a script or command to run on the host to get its return body.

https://caddyserver.com/docs/websocket

Try the websocket preset for the proxy directive:

https://caddyserver.com/docs/proxy#presets

Which adds the necessary upgrade headers - the proxy directive already supports websockets, the client just needs to be made aware of this.