Traefik Reverse Proxy



  • Traefik is a reverse proxy that integrates well with things like Docker, K8s, Consul, etcd, etc. However it has a nice file mode also. It's written in Go so it's a single static binary and doesn't need restarted with config changes. If your application has health checks, you can leverage those as well. You can get the binary from the releases page.

    By default it looks for the config traefik.toml in /etc/traefik/, $HOME/.traefik, or the directory the executable is in. It's simple to set up. Here's the full file for a single backend:

    traefik.toml

    defaultEntryPoints = ["http"]
    [entryPoints]
      [entryPoints.http]
      address = ":80"
    
    [file]
    
    [backends]
      [backends.backend1]
        [backends.backend1.servers.server1]
           url = "http://10.1.30.134"
    
    [frontends]
      [frontends.frontend1]
          backend = "backend1"
          passHostHeader = true
          [frontends.frontend1.routes.example]
              rule = "Host:staticpage.test.com"
    

    If you want to enable the dashboard, it would look like this:

    defaultEntryPoints = ["http"]
    [entryPoints]
      [entryPoints.http]
      address = ":80"
    
    [api]
      entryPoint = "traefik"
      dashboard = true
      address = ":8080"
    
    [file]
    
    [backends]
      [backends.backend1]
        [backends.backend1.servers.server1]
           url = "http://10.1.30.134"
    
    [frontends]
      [frontends.frontend1]
          backend = "backend1"
          passHostHeader = true
          [frontends.frontend1.routes.example]
              rule = "Host:staticpage.test.com"
    

    Then visiting port 8080 gives you the dashboard:

    traefik-dashboard.png



  • Are you currently using it in production?



  • @flaxking said in Traefik Reverse Proxy:

    Are you currently using it in production?

    Not at work. I'm using it for projects outside of that though. My docker compose stack at home uses it.


Log in to reply