Relative URL using pathprefix

Hi,

I run Traefik 2 on a kubernetens cluster (microk8s)

I am using Traefik succesfully using subdomains in front of my domainname to route to my containers.
When I try to route based on a path I think I am stumbling on containers that serve webpages relative to root.

Example:

gitea.mydomain,com works fine.

www.mydomain.com/gitea dos not work.

I tried to use stripprefix in a middleware but I think that is nog enough.

Is ther an aexample yaml how to do this?

Would appreciate help on this.

My route:

kind: IngressRoute
metadata:
name: gitea-http
spec:
entryPoints:
- web
routes:

  • match: Host(www.mydomain.com) && PathPrefix(/gitea/)
    kind: Rule
    middlewares:
  • name: gitea-middleware
    namespace: default
    services:
    • name: gitea
      port: 3000

My middleware:

kind: Middleware
metadata:
name: gitea-middleware
spec:
stripPrefix:
prefixes:

  • /gitea
    forceSlash: false

This probably does not work, because the service is returning absolute URLs as redirect or links (like /login). You can only make it work when you can make the service path-aware, meaning it returns the correct full path.

This is why usually sub-domains are used instead of paths.

I think there is a middleware to filter and replace (regex), that would go though all the data returned by the service, so probably really not recommendable.