aboutsummaryrefslogtreecommitdiff
path: root/src/reverse_proxy.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-08 17:27:27 +0100
committerAlex Auvolat <alex@adnab.me>2021-12-08 17:27:27 +0100
commit8d47bef9d45a767fcc166d26b75fc51937116bcd (patch)
treed51526af4ebdfc076b43284f537d05ca211420d2 /src/reverse_proxy.rs
parentc49b2075a30460a319ce53da300e4943d45d5add (diff)
downloadtricot-8d47bef9d45a767fcc166d26b75fc51937116bcd.tar.gz
tricot-8d47bef9d45a767fcc166d26b75fc51937116bcd.zip
Fix path prefixes
Diffstat (limited to 'src/reverse_proxy.rs')
-rw-r--r--src/reverse_proxy.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/reverse_proxy.rs b/src/reverse_proxy.rs
index 3d2a1fc..1768724 100644
--- a/src/reverse_proxy.rs
+++ b/src/reverse_proxy.rs
@@ -72,10 +72,9 @@ fn create_proxied_request<B>(
*builder.headers_mut().unwrap() = remove_hop_headers(request.headers());
- let host_header_name = "host";
- let x_forwarded_for_header_name = "x-forwarded-for";
// If request does not have host header, add it from original URI authority
+ let host_header_name = "host";
if let Some(authority) = request.uri().authority() {
if let hyper::header::Entry::Vacant(entry) =
builder.headers_mut().unwrap().entry(host_header_name)
@@ -85,6 +84,7 @@ fn create_proxied_request<B>(
}
// Add forwarding information in the headers
+ let x_forwarded_for_header_name = "x-forwarded-for";
match builder
.headers_mut()
.unwrap()
@@ -100,6 +100,8 @@ fn create_proxied_request<B>(
}
}
+ builder.headers_mut().unwrap().insert(HeaderName::from_bytes(b"x-forwarded-proto")?, "https".try_into()?);
+
if let Some(conn) = request.headers().get("connection") {
if conn.to_str()?.to_lowercase() == "upgrade" {
if let Some(upgrade) = request.headers().get("upgrade") {