Passing path suffix to service

I'm trying to figure out how to pass the end of a path onto the selected services but I can't figure out how to craft the rule. My services are running on ECS but I don't think that matters really.

Let's say I have two services running but each service actually serves two endpoints (e.g. /dashboard and /admin). I want to have traffic routed something like as follows:

  • --> service1:8080/dashboard
  • --> service1:8080/admin
  • --> service2:8080/dashboard
  • --> service2:8080/admin

So I'd like to capture any request to{$PATH_SUFFIX} and then point that to service1:8080/{$PATH_SUFFIX}. I've tried using PathPrefix but that just directs everything matching to service1:8080. I can't figure out how to capture and pass on the needed portion of the path to the actual service.

I suspect the solution is either using a redirect somehow or the middleware tools, but I've struggled to find good examples of this particular scenario. Thanks!

Hello @sterlinm

The way you have described it you will want to use the stripPrefix middleware to remove /app1 and /app2 on those routers.


If you were doing app1,app2,....,appN then the stripPrefixRegex would be the one to use.

1 Like

Great thanks! What would my rule by in that context?


Or something like that? Thanks for the quick response!

That looks fine. If you are using more than one domain you might want to combine that with a Host(``) rule too.

Okay great. Honestly, I'm getting stuck with 404s even without trying to get the part with the suffix working. I've got a service I can go to directly (e.g. HTTP://xx.yy.zz.aa:8080) and I've got a service for it in my dashboard with a rule that looks like Path(/service) but I can't seem to access it through the machine running traefik, whether or not I include a Host(``) rule.

I'll keep playing around with it but I think I'm misunderstanding something fundamental about Host and Path rules. Thanks again for your help.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.