This episode takes Traefik beyond HTTP: TCP entrypoints and routers with the HostSNI rule, TLS termination versus passthrough for databases, SSH, and SMTP, UDP entrypoints with load balancing, and real examples for DNS and game servers.

So far all Traefik routing has dealt with HTTP. But Traefik is also a capable TCP and UDP proxy: PostgreSQL databases, SSH, SMTP, DNS, and game servers can all pass through the same gateway, with flexible routing rules and TLS passthrough.
Episode 18 dissects three layers: TCP routers with HostSNI, UDP routers, and the TLS passthrough pattern. By understanding these, you can centralize all your network access — not just web — into a single control point.
A TCP entrypoint is defined with the tcp protocol. Naming is free, e.g. ssh, db, or smtp:
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
ssh:
address: ":2222"
db:
address: ":5432"TCP routers use HostSNI as the main matcher — the same value as SNI in the TLS handshake. An example TCP router for a PostgreSQL database, complete with the equivalent traefik.tcp.routers.pg.rule label alternative in Docker:
tcp:
routers:
pg-internal:
rule: "HostSNI(`pg.internal.local`)"
entrypoints:
- db
service: pg-svc
tls:
passthrough: true
services:
pg-svc:
loadBalancer:
servers:
- address: "10.0.0.80:5432"Note tls.passthrough: true: Traefik does not decrypt the connection, only sees SNI to decide the route, then forwards the raw stream to PostgreSQL. The backend holds the certificate and handles TLS entirely.
tcp:
routers:
smtp-secure:
rule: "HostSNI(`mail.example.com`)"
entrypoints:
- smtp
service: smtp-svc
tls: {}
services:
smtp-svc:
loadBalancer:
servers:
- address: "10.0.0.90:2525"The SMTP router above uses tls: {} — Traefik handles TLS with the available certificates, then forwards plaintext to the backend on an internal port. The best time to choose termination: you want a single place for certificates; the best time for passthrough: end-to-end security is mandatory.
HostSNI route per instance, terminate or passthrough as needed.For protocols that do not use TLS at all (e.g. raw SSH), Traefik provides a special matcher: the HostSNI(*) rule matches all connections and directs them to the chosen service. This is the pattern used for single-purpose entrypoints:
tcp:
routers:
ssh-gateway:
rule: "HostSNI(`*`)"
entrypoints:
- ssh
service: ssh-svc
services:
ssh-svc:
loadBalancer:
servers:
- address: "10.0.0.100:22"UDP works similarly to TCP, with one big difference: there is no handshake. For that reason, UDP routers use the HostSNI(*) rule to accept all datagrams on their entrypoint:
entryPoints:
dns-udp:
address: ":53/udp"
udp:
routers:
dns-router:
rule: "HostSNI(`*`)"
entrypoints:
- dns-udp
service: dns-svc
services:
dns-svc:
loadBalancer:
servers:
- address: "10.0.0.110:53"UDP load balancing in Traefik forwards datagrams to a server selected based on the route; because of its connectionless nature, server selection uses a hash of the source address to keep conversation consistency.
Tip
Do not mix UDP and TCP on the same entrypoint. The :53 (TCP) and :53/udp entrypoint definitions are two separate entities — create two differently named entrypoints to keep things clear.
Key takeaways:
HostSNI as the matcher; HostSNI(*) covers everything.HostSNI(*) and can load-balance datagrams.In episode 19 next we will cover file provider & dynamic configuration — writing routers, services, and middlewares in YAML/TOML files, directory watching with hot reload, the http, tcp, udp, and tls section structure, and best practices for non-container services. Your gateway can now manage anything without Docker.