I am trying to setup traefik for routing postgres instances. I have figured I have to use the new TCP feature in treafik 2.0. However I am struggling to figure it out.
Anyone got any tips or working examples?
My staring point is the "getting started" section, and tried to include a postgres db. I am able to reach the whoami instance, but not the postgres instance
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"
Testing my postgres connection with:
psql -h postgres.docker.localhost -U postgres -d postgres -p 80
This works if I set HostSNI('*'), but not a real solution. Also testet with "Host" instead of "HostSNI"