我正在试图让docker中的家庭助手在traefik后面运行,我想我和其他使用websockets的应用程序有类似的问题。首页加载,但当我尝试登录时,只是说连接...并继续旋转。
我用chrome打开调试器,看看:
WebSocket connection to 'ws://home-assistant.docker.int.xxx.com/api/websocket' failed: WebSocket opening handshake timed out
如果我将端口直接传递给主机(即http://docker.int.xxx.com:8123),则可以正常工作。
我打开了traefik中的调试日志记录,这是唯一相关的消息:
time="2017-07-08T01:58:18Z" level=debug msg="Writing outgoing Websocket request to target connection: &{Method:GET URL:ws:/api/websocket Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Cache-Control:[no-cache] Connection:[Upgrade] User-Agent:[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36] Accept-Language:[en-US,en;q=0.8] Sec-Websocket-Version:[13] Cookie:[__zlcmid=eqgBjgiVtncb4A; _ga=GA1.2.930888288.1496028630] Sec-Websocket-Extensions:[permessage-deflate; client_max_window_bits] Accept-Encoding:[gzip, deflate] Origin:[http://home-assistant.docker.int.xxx.com] Upgrade:[websocket] Sec-Websocket-Key:[FsZu8u+pr9IQDAc3xZYiVQ==] Pragma:[no-cache]] Body:{} GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:home-assistant.docker.int.xxx.com Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:192.168.2.1:49364 RequestURI:/api/websocket TLS:<nil> Cancel:<nil> Response:<nil> ctx:0xc4206ce4c0}"
在我的home-assistant配置中,我确保更新base_url。
http:
# Uncomment this if you are using SSL or running in Docker etc
base_url: home-assistant.docker.int.xxx.com
traefik.toml:
debug = true
logLevel = "debug"
defaultEntryPoints = ["http", "https", "ws", "wss"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
InsecureSkipVerify = true
... acme and some manual backends ...
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "docker.int.xxx.com"
我的docker run.sh:
docker run -d --name="home-assistant" \
--restart=always \
-v $PWD/config:/config \
-v /etc/localtime:/etc/localtime:ro \
--network=traefik-net \
-p 8123:8123 \
--label traefik.port=8123 \
--label traefik.docker.network=traefik-net \
homeassistant/home-assistant
我的traefik-net上有其他容器,所以我知道它一般都在工作。我在v1.3.2上,现在v1.3.3仍然没有任何运气。我发现其他帖子解决了nginx,apache和haproxy的问题,但对于traefik没什么。