Implementing reverse proxy with dynamic domain-to-path substitution

Hello,

I'm trying to set up a reverse proxy using Traefik that forwards requests to a backend service while adding the requested domain as part of the path and preserving the remaining path after the domain, if present. The goal is to transform incoming requests as follows:

example.com => http://backend-service:53000/example.com
sub.example.com => http://backend-service:53000/sub.example.com
sub.example.com/shop => http://backend-service:53000/sub.example.com/shop

I have attempted various configurations, but I couldn't find a way to achieve this using variables in the service URL or middleware configurations within Traefik. Is there a way to accomplish this dynamic domain-to-path substitution along with preserving the remaining path using Traefik? Any guidance or examples would be greatly appreciated.

Thank you for your assistance!

I don’t think that it is possible with an out-of-the-box dynamic solution. You can check the official middleware again, check existing third party plugins or write your own.