Traefik As A TCP Reverse Proxy
In case you haven’t heard of it, Traefik is a load balancer and reverse proxy.
Its selling point is that it is simple to use and operate and integrates well with containerized workflows.
I plan on using Traefik as an HTTP load balancer for my side project. But I also just learned you can use it as a TCP proxy.
This means you can use it for SSH, SMTP, AMQP, etc.
Here’s an example:
# Define TCP router
[tcp.routers]
[tcp.routers.my-tcp-router]
entryPoints = ["websecure"]
rule = "HostSNI(`mydomain.com`)" # Use `*` to match any SNI
service = "my-tcp-service"
# Define TCP service
[tcp.services]
[tcp.services.my-tcp-service.loadBalancer]
[[tcp.services.my-tcp-service.loadBalancer.servers]]
address = "internal-service-ip:port"
Resources:
- https://doc.traefik.io/traefik/routing/routers/#configuring-tcp-routers
- https://stackoverflow.com/questions/61394843/using-traefik-2-as-tcp-proxy-for-mariadb-docker
Master GitHub Actions with a Senior Infrastructure Engineer
As a senior staff infrastructure engineer, I share exclusive, behind-the-scenes insights that you won't find anywhere else. Get the strategies and techniques I've used to save companies $500k in CI costs and transform teams with GitOps best practices—delivered straight to your inbox.
Not sure yet? Check out the archive.
Unsubscribe at any time.