{Will pay for help!} Websockets Reverse Proxy

1. Caddy version (caddy version):

v2.1

2. How I run Caddy:

caddy run

a. System environment:

Windows Server 2016

b. Command:

caddy run

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config:

:43001 {
reverse_proxy {
to 10.0.0.102:4000
header_up Host {http.reverse_proxy.upstream.host}
header_up X-Real-IP {http.request.remote_host}
header_up X-Forwarded-For {http.request.remote_host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
}

@websockets {
header Connection * Upgrade *
header Upgrade websocket

}

}

3. The problem I’m having:

I want to send Websocket requests (wss) coming in on port 43001 to other socket servers. Im not getting a proper socket handshake on the socket server side.

4. Error messages and/or full log output:

2020/07/07 17:54:46.419 ←[31mERROR←[0m http.handlers.reverse_
with incomplete response {“error”: “context canceled”}

Socket Server is getting the connection but fails handshake, therefore closes connection.

5. What I already tried:

Tried so many examples and read docs, I cant figure this out.

Doesnt seems like Im needing it to do much, just a simple load balancer…

Current CaddyFile is:

:43001 {
log {
level DEBUG
output file caddy_test.log {
roll_size 10MiB
roll_keep 10
roll_keep_for 336h
}
}

handle_path /* {
reverse_proxy 10.0.0.102:4000
}
}

Client is disconnecting because of failed handshake… I dont know what Im doing wrong…

}

6. Links to relevant resources:

For paid help please see this page:

At a glance it seems the issue is due to TLS not being enabled, or the upstream expecting TLS and the proxy request not having TLS.

For the former, try using a domain name and port 443 to let Caddy automatically set up TLS.

For the later, try enabling the tls http transport option of the reverse_proxy directive.

Please use ``` on the lines before and after your config to use code formatting in your forum posts, it will preserve whitespace and make it much more readable. It’s hard to follow as-is.

This topic was automatically closed after 30 days. New replies are no longer allowed.