【发布时间】:2019-08-24 23:39:29
【问题描述】:
我正在尝试设置 traefik 以路由 postgres 实例。 我想我必须使用 treafik 2.0 中的新 TCP 功能。但是我正在努力弄清楚。
有人有任何提示或工作示例吗?
我的起点是“入门”部分,并尝试包含一个 postgres 数据库。我可以访问 whoami 实例,但不能访问 postgres 实例
docker-compose.yaml
version: '2'
services:
reverse-proxy:
image: traefik:v2.0.0-alpha3 # The official v2.0 Traefik docker image
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
- /home/mariufa/tmp/traefik.toml:/etc/traefik/traefik.toml
whoami:
image: containous/whoami # A container that exposes an API to show its IP address
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
postgres:
image: postgres:latest
labels:
- "traefik.tcp.routers.postgres.rule=HostSNI(`postgres.docker.localhost`)"
traefik.toml
[api]
[entrypoints]
[entrypoints.web]
address = ":80"
[providers.docker]
endpoint = "unix:///var/run/docker.sock"
测试我的 postgres 连接:
psql -h postgres.docker.localhost -U postgres -d postgres -p 80
如果我设置了 HostSNI('*'),这可行,但不是真正的解决方案。 也使用“Host”而不是“HostSNI”来测试
【问题讨论】:
标签: traefik