Why doesn't traefik readd PathPrefix prefixes to backend responses?

Hi, I am currently wondering, why traefik is not able to re add prefixes from the PathPrefixStrip to backend responses.

I suspect there is a meaning behind this, but I can't see which one. This is from the v2 documentation:

If your backend is serving assets (e.g., images or Javascript files), chances are it must return properly constructed relative URLs. Continuing on the example, the backend should return /products/shoes/image.png (and not /images.png which Traefik would likely not be able to associate with the same backend).

That is what is confusing me: Why is Traefik designed in such a way that the backend has to return a path that includes the prefix?

Background why I am asking: I want to map certain path prefixes on the same host to certain docker containers. This does not work with backend redirects. An example is Grafana.

Configuring a path prefix for "/grafana/" and calling "/grafana" itself works, but then Grafana redirects to "/login" which is not correct. I'd need "/grafana/login" and so on, you get the picture.

So again, why is the system designed that way? I will happily change my approach if someone tells me I am not doing it the way id is supposed to be done.

Thanks :slight_smile:

Hello @FabianTe,

Short answer: Traefik does not modify the body of requests.

Doing so would affect performance, and would cause a myriad of other issues.

For this reason, most modern applications allow for a "base URL" or a "root domain".

Grafana has an entire page of their documentation showing how to configure grafana to run behind a reverse proxy: (https://grafana.com/docs/installation/behind_proxy/). They recognize that this is a standard reverse-proxy practice, and have ensured that it is easy to configure.


that sounds logical.

Thanks for the link :+1: I hope that the systems I use are all "proxy compatible".

Thank you!