How to use Traefik.io as Static Proxy

Traefik.io is a very cool open source project, providing a powerful reverse proxy. The project is focusing mainly on container based architectures like Docker Swarm. In such an environment Traefik.io is able to recognize new containers in a network and dynamically computes the route from the frontend to the corresponding backend service. I wrote about this functionality in combination with docker swarm already in my blog: Lightweight Docker Swarm Environment. This concept is also part of the Imixs-Workflow project.

But what if you just want to add a kind of static route, which has nothing to do with container based services. I had this situation as I wanted to redirect incoming requests for a specific host name to an external server – outside of my docker swarm.

To realize this, you can add a front-end rule under the section [file] at the end of your traefik.toml file. This is an example how such a rule can looks like:

...
[file]

[backends]
 [backends.backend1]

 [backends.backend1.servers]
   [backends.backend1.servers.server0]
   url = "http://some.host.de:12345"
   # note that you cannot add path in 'url' field
 
[frontends]
  [frontends.frontend1]
  entryPoints = ["http"]
  backend = "backend1"
  passHostHeader = true
  [frontends.frontend1.routes]
    [frontends.frontend1.routes.route0]
    rule = "Host:www.myweb.com"

This rule proxies requests for “www.myweb.com” to the host “some.host.de:12345”. See also the discussion here.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.