Websocket proxy condition

With HAProxy, I can do something like this:

acl		is_websocket hdr(Upgrade) -i WebSocket
use_backend	ws if is_websocket

I need to be able to have the websocket server on the root of the domain, but I can’t seem to get it to work with Caddy. Is there somekind of conditional to allow any other connection to / go through to php while ones with the upgrade header get proxied to my websocket server (at :8888)?


Edit: found that I can do the following to make it work…

rewrite / {
    if {>Connection} is Upgrade
    if {>Upgrade} is websocket
    to /websocket
proxy /websocket websocket:8888 {
    without /websocket
1 Like

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