Path Redirection

Hi, I'm trying to set up Traefikv2 to redirect any request from / -> /foo, and seem to be running into an issue that I'm missing completely. I don't seem to be getting any errors in the Traefik log. I would just serve it off / but there are other backends I eventually want to serve on different paths.

Thanks in advance!

Here is my traefik.toml:

    address = ":80"
    address = ":443"

    filename = "rules.toml"
    watch = true

  level = "DEBUG"

  insecureSkipVerify = true

Here's my rules.toml:

    rule = "HostRegexp(`{any:.+}`)"
    entryPoints = ["web"]
    middlewares = ["https_redirect"]
    service = "foo-service"
    rule = "Path(`/`)"
    middlewares = ["root_redirect"]
    service = "foo-service"
    rule = "PathPrefix(`/foo`)"
    entryPoints = ["websecure"]
    service = "foo-service"
    middlewares = ["foo_prefix_strip"]

      certFile = "ssl.crt"
      keyFile = "ssl.key"

    url = "http://localhost:8080"

    scheme = "https"
    permanent = true
    path = "/foo"
    prefixes = ["/foo"]

I previously did it in Traefikv1.7 with something like this:

  regex = "&https?://(.*)/(.*)"
  replacement = "https://$1/foo/$2"
  permanent = true

I believe I figured out the issue!

I needed to add this line to my two HTTPS routers (foo_root_forward & foo):


foo being w/e your router name is (foo or foo_root_forward in my case)

If I understand your question, why do not use RedirectRegex ?
ReplacePath is for the backend.
So, as far as I understand, ReplacePath adds /foo and StripPrefix removes /foo, so it is basically a null operation.
Am I wrong?