actix / actix/actix-web

Support for `X-Forwarded-Prefix`

Offen
#3,143 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
A-web C-feature
Vorherrschende Sprache
Rust
Sterne
24.8k
Forks
1.9k
Ø Merge
23 Std. 10 Min.
Gemergte PRs (30 T.)
26

Beschreibung

## 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.