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:
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
[providers]
[providers.file]
filename = "rules.toml"
watch = true
[log]
level = "DEBUG"
[serversTransport]
insecureSkipVerify = true
Here's my rules.toml:
[http.routers]
[http.routers.http_forwarder]
rule = "HostRegexp(`{any:.+}`)"
entryPoints = ["web"]
middlewares = ["https_redirect"]
service = "foo-service"
[http.routers.foo_root_forward]
rule = "Path(`/`)"
middlewares = ["root_redirect"]
service = "foo-service"
[http.routers.foo]
rule = "PathPrefix(`/foo`)"
entryPoints = ["websecure"]
service = "foo-service"
middlewares = ["foo_prefix_strip"]
[tls.stores]
[tls.stores.default]
[tls.stores.default.defaultCertificate]
certFile = "ssl.crt"
keyFile = "ssl.key"
[http.services]
[[http.services.foo-service.loadBalancer.servers]]
url = "http://localhost:8080"
[http.middlewares]
[http.middlewares.https_redirect.redirectScheme]
scheme = "https"
permanent = true
[http.middlewares.root_redirect.replacePath]
path = "/foo"
[http.middlewares.foo_prefix_strip.stripPrefix]
prefixes = ["/foo"]
I previously did it in Traefikv1.7 with something like this:
[frontends.frontend_redir.redirect]
regex = "&https?://(.*)/(.*)"
replacement = "https://$1/foo/$2"
permanent = true