Description
Expected Behavior
Reverse proxies have the ability to deploy specific routes behind a URL-prefix.
This allows multiple webservers to serve on the same site without having to adapt their respective frontend.
The reverse proxy takes care of stripping the URL-prefix out of incoming requests,
but it is the responsibility of the backend-server to re-attach this prefix to links served on site.
Example: https://doc.traefik.io/traefik/middlewares/http/stripprefix/
Current Behavior
Currently Actix has no support for this and (resource-)links served on site will break.
Possible Solution
The server can utilize the X-Forwarded-Prefix
attached by the reverse proxy to reconstruct the expected relative site-root.
Quote from traefik docs:
If your backend is serving assets (e.g. images or JavaScript files), it can use the X-Forwarded-Prefix header to properly construct relative URLs. Using the previous example, the backend should return /products/shoes/image.png
(and not /image.png
, which Traefik would likely not be able to associate with the same backend).
Here is what aspnetcore did: dotnet/aspnetcore#23263
Steps to Reproduce (for bugs)
- Host an Actix server behind a reverse proxy
- Strip the URL-prefix
Context
Without this feature it is a lot harder to share a single domain between multiple webservers.
Your Environment
Actix with Leptos behind Traefik.
- rustc 1.74.0-nightly (65ea825f4 2023-09-18)
- Actix Web Version: 4.4.0