Support for `X-Forwarded-Prefix`
- Lenguaje dominante
- Rust
- Estrellas
- 24.8k
- Forks
- 1.9k
- Merge medio
- 23 h 10 min
- PR fusionados (30 d)
- 26
Descripción
## 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](https://doc.traefik.io/traefik/middlewares/http/stripprefix/):
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: https://github.com/dotnet/aspnetcore/issues/23263
## Steps to Reproduce (for bugs)
1. Host an Actix server behind a reverse proxy
2. 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
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.