Simulate nginx proxy_pass with regex

Hello,
I need route a specific path with regex, by one service to another, example with nginx is this:

location ~ /example-com/foo/(.*)$ {
    proxy_pass http://service02/bar/$1;
}

I tried to make service01-foo rule in this way:

services:
  service01:
    ...
    ...
    labels:
      - "traefik.http.routers.service01.rule=Host(`example.com`)"
      - "traefik.http.services.service01.loadbalancer.server.port=80"
      - "traefik.http.routers.service01-foo.rule=Host(`example.com`) && PathRegexp(`/foo/(.*)`)"
      - "traefik.http.services.service01-foo.loadbalancer.server.url=http://service02/bar/$${1}"

  service02:
    ...
    ...

But i read here Traefik Services Documentation - Traefik :

Paths in the servers' url have no effect, If you want the requests to be sent to a specific path on your servers, configure your routers to use a corresponding middleware

What can I do?

Thanks

loadbalancer.servers.url is sadly not supported by providers.docker, only by dynamic config file via providers.file.

Docker labels can only target the service/container they belong to, you can only set scheme and port.

If I use providers.file could it work this way?

Should work when you define router and service in dynamic config file for the "external" URL.

PathPrefix() is probably easier than regex.