How to properly proxy websockets with caddy

1. My Caddy version (caddy -version):

latest build from master

2. How I run Caddy:

Please provide all of the relevant information and DO NOT REDACT anything except passwords/keys. Thank you!

a. System environment:

OS, relevant versions, systemd? docker? etc.
Ubuntu 18.04

b. Command:

caddy --conf=Caddyfile

d. My complete Caddyfile:

mydomain.com {
  log / stdout
  errors ./errors.log
  proxy /ws 127.0.0.1:8082 {
    without /ws
    websocket
  }
}

also tried

mydomain.com {
  log / stdout
  errors ./errors.log
  websocket / 
} #and don't know what to do next, though like this connection has been established, but to a plain socket server, not to my own, that I'm running on port 8082

3. The problem I’m having:

Please describe the issue thoroughly enough so that anyone can reproduce the exact behavior you’re seeing. Be as specific as possible.
can’t configure caddy to proxy my wss server properly.

4. Error messages and/or full log output:

Please DO NOT REDACT any information except passwords/keys.

nothing fancy on caddys side, but on the front end in my console I see Error during WebSocket handshake: Unexpected response code: 400 with socket code 1006 and no log on the socket server when doing with proxy, and absolutely no output when doing websocket /

Hi @mordigan, welcome to the Caddy community.

What URL, exactly, does the websocket request go to?

to 127.0.0.1:8082 where my socket server is.

If your browser is making requests to 127.0.0.1:8082, those requests aren’t going through Caddy.

Caddy is listening on HTTP port 80 and HTTPS port 443.

Your client will need to make its websocket requests on those ports, preferably via the same hostname you access your site through Caddy.

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