Websocket issues from 2.9*
Issue Details
so recently i needed to create a new docker build for my work which i have used before, however because i was using latest tag in the builder the version of caddy was much greater than the last time i built it, and this has highlighted some issues with websockets, i then worked back with the builder numbers until i got to 2.8 where everything is working again.
basically when reverse_proxying a websocket it closes the connection without any valid reason.
here is the dockerfile
FROM caddy:2.8-builder-alpine AS builder
RUN xcaddy build \
--with github.com/caddy-dns/cloudflare@188b4850c0f2f5565a6310810c936ea960e2210f \
--with github.com/caddy-dns/[email protected]
FROM caddy:alpine
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
here is the Caddyfile (anonymized)
*.mydomain.com *.dev.mydomain.com {
#PORTAL
@portal_http {
host portal.dev.mydomain.com
}
@portal_ws {
host portal.dev.mydomain.com
header Connection *Upgrade*
header Upgrade websocket
}
handle @portal_ws {
header {
Identifier "soketi"
}
reverse_proxy portal_soketi:6001 {
header_up Connection {http.request.header.Connection}
header_up Upgrade {http.request.header.Upgrade}
}
}
reverse_proxy @portal_http portal_web {
header_up Host {host}
header_up X-Real-IP {remote}
header_up X-Forwarded-Port 443
health_timeout 5s
}
tls {
dns route53
}
}
Assistance Disclosure
No response
If AI was used, describe the extent to which it was used.
websockets not working from builder version 2.9 upwards.
What are the relevant logs for those websocket requests? How are these requests logged if caddy 2.8 is used?
Remove all your header_up lines, none of them do anything useful. Caddy already passes through the relevant HTTP headers, including X-Forwarded-For.
I had the same problem, too - #7292 appears to have fixed the issue.
#7292 fixed issue where tls server name contains placeholders and is for version 2.10.1, which doesn't apply in this issue.