Caddy Websocket Configuration

Hey y’all,

I’m using Zammad via docker compose with a downstream caddy ingress server that handles all the requests - the UI does work as expected, but there is no connection made to the Websocket server. Does anybody have a sample caddyfile configuration to take a look on how to handle websocket connections properly?
This is my current, for websockets non working caddy configuration:

SAMPLEDOMAIN.com {
    encode gzip
    header Strict-Transport-Security "max-age=31536000;"

    reverse_proxy http://127.0.0.1:1225 {
        # Caddy automatically upgrades connections to HTTP/2 where possible.
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Port {server_port}
        header_up X-Forwarded-Proto {scheme}
        header_up Connection {>Connection}
        header_up Upgrade {>Upgrade}
    }

        @ws {
                header Connection *Upgrade*
                header Upgrade websocket
        }
   # WebSocket configuration
    reverse_proxy /ws http://127.0.0.1:4353 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Port {server_port}
        header_up X-Forwarded-Proto {scheme}
        header_up Connection {>Connection}
        header_up Upgrade {>Upgrade}
    }
}

Thanks and all the best!
Paul

Hey Paul,

if you’re using an actual Version of Caddy Server 2.x, the websockets will be handled automatically. There should be no need of an extra @ws section.

We are running caddy as reverse proxy in an “undockered” environment, but the config file should look quite straight forward:

zammad.example.com {
	reverse_proxy localhost:3000
}

No more magic needed.