make Traefik route to a service on the same machine at a different port

Viewed 39

I have a service(myapp) running on a node at port 5678. I'm running Traefik on the same node(e.g. myip). How do I make Traefik route any requests to http://myip/myapp to the myapp service running at port 5678?

1 Answers

In Traefik 2.x you can use redirectRegex in middlewares:

middlewares:
    cleanerRegex:
         redirectRegex:   # <== this is it!
             regex: "^http?://example.com/myapp"
             replacement: "https://example.com:5678/"
[...]
Related