【发布时间】:2019-10-05 21:54:06
【问题描述】:
我正在尝试将 traefik 配置为在同一域上提供 http、https、ws、wss。这是我的 traefik 初始化(docker-compose.yml):
command:
- "storeconfig"
- "--api"
- "--entrypoints=Name:http Address::80 Redirect.EntryPoint:https"
- "--entrypoints=Name:https Address::443 TLS"
- "--entrypoints=Name:ws Address::8081 Redirect.EntryPoint:wss"
- "--entrypoints=Name:wss Address::8083 TLS"
- "--defaultentrypoints=http,https"
- "--acme"
- "--acme.entryPoint=https"
- "--acme.httpChallenge.entryPoint=http"
- "--acme.onHostRule=true"
- "--acme.onDemand=false"
- "--acme.email=${EMAIL}"
- "--acme.storage=etc/traefik/acme/acme.json"
- "--docker"
- "--docker.swarmMode"
- "--docker.watch"
并为 ws/wss 服务部署标签:
deploy:
labels:
- traefik.enable=true
- traefik.backend=ws-container-name
- traefik.frontend.rule=Host:myhost
- traefik.frontend.entryPoints=ws,wss
- traefik.docker.network=traefik
- traefik.port=9001
结果:ws 有效,wss 无效。
% wscat -c ws://myhost:8081
connected (press CTRL+C to quit)
% wscat -c wss://myhost:8083
error: unable to verify the first certificate
http、https(另一个容器)运行良好
为什么 traefik 不为 wss 提供证书?
【问题讨论】:
-
为了帮助他人帮助您,最好提供minimal working example。在这种情况下,您可以将启动 traefik 的
docker-compose.yml与您要测试的几个 echo 服务放在一起。 -
我解决了将 traefik 更新到 v2 的问题,因为在 v1.7 中似乎无法完成这项工作。我在下面发布了答案。
标签: docker ssl docker-compose docker-swarm traefik