Skip to content

Proxy a Websocket server not work as expect #4006

@kevinanew

Description

@kevinanew

Do you want to request a feature or report a bug?

Bug

What did you do?

proxy a websocket server

What did you expect to see?

a proxy websocket server work like the source server.

What did you see instead?

websocket: bad handshake with resp: 404

Output of traefik version: (What version of Traefik are you using?)

Version:      v1.7.2
Codename:     maroilles
Go version:   go1.11.1
Built:        2018-10-04_01:44:36PM
OS/Arch:      linux/amd64

What is your environment & configuration (arguments, toml, provider, platform, ...)?

logLevel = "DEBUG"

defaultEntryPoints = ["http"]

[entryPoints]
  [entryPoints.http]
  address = ":80"

[file]

  [frontends]
    [frontends.staging]
    backend = "staging"
    [frontends.staging.routes.server1]
    rule = "Host:localhost"

  [backends]
    [backends.staging]
      [backends.staging.servers.api]
      url = "http://echo.websocket.org"

Anyone can use this config to reproducing this bug.
Save the content to a file test.toml

Then run:

traefik -c test.toml

In another termail:

wscat -c "ws://localhost"

please install wscat if you don't have: npm install -g wscat

If applicable, please paste the log output in DEBUG level (--logLevel=DEBUG switch)

DEBU[2018-10-10T16:49:31+08:00] vulcand/oxy/roundrobin/rr: begin ServeHttp on request  Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Connection\":[\"Upgrade\"],\"Sec-Websocket-Extensions\":[\"permessage-deflate; client_max_window_bits\"],\"Sec-Websocket-Key\":[\"yOE9GHwluJ7jeYGO0m2wPg==\"],\"Sec-Websocket-Version\":[\"13\"],\"Upgrade\":[\"websocket\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"1.us.api.foo.org:443\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"171.210.196.254:19766\",\"RequestURI\":\"/\",\"TLS\":null}"
DEBU[2018-10-10T16:49:31+08:00] vulcand/oxy/roundrobin/rr: Forwarding this request to URL  ForwardURL="wss://echo.websocket.org" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Connection\":[\"Upgrade\"],\"Sec-Websocket-Extensions\":[\"permessage-deflate; client_max_window_bits\"],\"Sec-Websocket-Key\":[\"yOE9GHwluJ7jeYGO0m2wPg==\"],\"Sec-Websocket-Version\":[\"13\"],\"Upgrade\":[\"websocket\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"1.us.api.foo.org:443\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"171.210.196.254:19766\",\"RequestURI\":\"/\",\"TLS\":null}"
DEBU[2018-10-10T16:49:31+08:00] vulcand/oxy/forward: begin ServeHttp on request  Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"wss\",\"Opaque\":\"\",\"User\":null,\"Host\":\"echo.websocket.org\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Connection\":[\"Upgrade\"],\"Sec-Websocket-Extensions\":[\"permessage-deflate; client_max_window_bits\"],\"Sec-Websocket-Key\":[\"yOE9GHwluJ7jeYGO0m2wPg==\"],\"Sec-Websocket-Version\":[\"13\"],\"Upgrade\":[\"websocket\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"1.us.api.foo.org:443\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"171.210.196.254:19766\",\"RequestURI\":\"/\",\"TLS\":null}"
DEBU[2018-10-10T16:49:31+08:00] vulcand/oxy/forward/websocket: begin ServeHttp on request  Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"wss\",\"Opaque\":\"\",\"User\":null,\"Host\":\"echo.websocket.org\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Connection\":[\"Upgrade\"],\"Sec-Websocket-Extensions\":[\"permessage-deflate; client_max_window_bits\"],\"Sec-Websocket-Key\":[\"yOE9GHwluJ7jeYGO0m2wPg==\"],\"Sec-Websocket-Version\":[\"13\"],\"Upgrade\":[\"websocket\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"1.us.api.foo.org:443\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"171.210.196.254:19766\",\"RequestURI\":\"/\",\"TLS\":null}"
ERRO[2018-10-10T16:49:32+08:00] vulcand/oxy/forward/websocket: Error dialing "1.us.api.foo.org:443": websocket: bad handshake with resp: 404 404 Not Found
DEBU[2018-10-10T16:49:32+08:00] vulcand/oxy/forward/websocket: completed ServeHttp on request  Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"wss\",\"Opaque\":\"\",\"User\":null  "Host\":\"echo.websocket.org\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Connection\":[\"Upgrade\"],\"Sec-Websocket-Extensions\":[\"permessage-deflate; client_max_window_bits\"],\"Sec-Websocket-Key\":[\"yOE9GHwluJ7jeYGO0m2wPg==\"],\"Sec-Websocket-Version\":[\"13\"],\"Upgrade\":[\"websocket\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"1.us.api.foo.org:443\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"171.210.196.254:19766\",\"RequestURI\":\"/\",\"TLS\":null}"
DEBU[2018-10-10T16:49:32+08:00] vulcand/oxy/forward: completed ServeHttp on request  Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"wss\",\"Opaque\":\"\",\"User\":null,\"Host\":\"echo.websocket.org\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Connection\":[\"Upgrade\"],\"Sec-Websocket-Extensions\":[\"permessage-deflate; client_max_window_bits\"],\"Sec-Websocket-Key\":[\"yOE9GHwluJ7jeYGO0m2wPg==\"],\"Sec-Websocket-Version\":[\"13\"],\"Upgrade\":[\"websocket\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"1.us.api.foo.org:443\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"171.210.196.254:19766\",\"RequestURI\":\"/\",\"TLS\":null}"
DEBU[2018-10-10T16:49:32+08:00] vulcand/oxy/roundrobin/rr: completed ServeHttp on request  Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Connection\":[\"Upgrade\"],\"Sec-Websocket-Extensions\":[\"permessage-deflate; client_max_window_bits\"],\"Sec-Websocket-Key\":[\"yOE9GHwluJ7jeYGO0m2wPg==\"],\"Sec-Websocket-Version\":[\"13\"],\"Upgrade\":[\"websocket\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"1.us.api.foo.org:443\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"171.210.196.254:19766\",\"RequestURI\":\"/\",\"TLS\":null}"

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions