问题描述
我正在尝试为WebSocket应用配置Traefik,我只是尝试在docker上使用一个简单的WS应用: https://hub.docker.com/r/jmalloc/echo-server/
I am trying to configure Traefik for a WebSocket app, I just try with a simple WS app on docker: https://hub.docker.com/r/jmalloc/echo-server/
要测试它,我使用Chrome SimpleWebSocketClient,因此,如果我使用应用程序的IP:Port,它可以正常工作.如果添加Traefik DNS,它会失败,我会尝试使用其他WS服务器和客户端,但也会失败,因此可能是Traefik.
To test it I use Chrome SimpleWebSocketClient, so if I use the IP:Port of the app it works fine. If I add the Traefik DNS it fails, I just try with other WS server and clients and fails too, so it would be something of Traefik.
我只是尝试使用Traefik版本:
I just try with Traefik versions:
-v1.3.0/raclette
-v1.2.3/morbier
这些是我的Traefik规则:
Those are my Traefik rules:
[backends.ws-test-backend]
[backends.ws-test-backend.LoadBalancer]
method = "drr"
[backends.ws-test-backend.servers.server1]
url = "ws://172.16.8.231:3000"
[frontends.ws-test-frontend]
backend = "ws-test-backend"
passHostHeader = true
entrypoints = ["http","https","ws", "wss"]
[frontends.ws-test-frontend.routes.manager]
rule = "Host:ws-test.ikcloud.ikerlan.es"
这可能是什么问题?建议使用反向代理吗?
What could it be wrong?Any recommended reverse proxy for doing this?
推荐答案
您需要为ws连接启用粘性会话,否则它将一直重新连接.
You need to enable sticky session for your ws connections, otherwise it will be reconnecting all the time.
[backends]
[backends.backend1]
# Enable sticky session
[backends.backend1.loadbalancer.stickiness]
这篇关于如何将Traefik用于WebSocket后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!