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:


Join the 80/20 DevOps Newsletter

If you're an engineering leader or developer, you should subscribe to my 80/20 DevOps Newsletter. Give me 1 minute of your day, and I'll teach you essential DevOps skills. I cover topics like Kubernetes, AWS, Infrastructure as Code, and more.

Not sure yet? Check out the archive.

Unsubscribe at any time.