Author: Jason White [github@jasonwhite.io]
Hash: 34b890db46815ce70aafd230e8e5600c39999493
Timestamp: Fri, 25 Jun 2021 06:39:16 +0000 (3 years ago)

+6 -1 +/-2 browse
Support X-Forwarded-Host header
Support X-Forwarded-Host header

Fixes #31. This should allow Rudolfs to work with load balancers.
1diff --git a/CHANGELOG.md b/CHANGELOG.md
2index 9361a81..5c42609 100644
3--- a/CHANGELOG.md
4+++ b/CHANGELOG.md
5 @@ -1,5 +1,9 @@
6 # Changelog
7
8+ ## WIP: v0.3.5
9+
10+ - Support X-Forwarded-Host headers to work better with load balancers. #31
11+
12 ## v0.3.4
13
14 - Fixed the S3 backend: 1c0d6c7e2638963e6755669c6013daae2fe47ee7
15 diff --git a/src/hyperext.rs b/src/hyperext.rs
16index 529998d..aec12b4 100644
17--- a/src/hyperext.rs
18+++ b/src/hyperext.rs
19 @@ -55,7 +55,8 @@ impl<B> RequestExt for Request<B> {
20
21 fn authority(&self) -> Option<Authority> {
22 self.headers()
23- .get(":authority")
24+ .get("X-Forwarded-Host")
25+ .or_else(|| self.headers().get(":authority"))
26 .or_else(|| self.headers().get("Host"))
27 .and_then(|authority| {
28 Authority::try_from(authority.as_bytes()).ok()