From 9f4b94724f9b164d2e2d08607780d5e85f53368e Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sun, 14 Jan 2024 17:35:03 +0100 Subject: [PATCH] Do not set Host header in proxied request If there is a reverse proxy downstream of hyper-reverse-proxy, and the forward_url is something like `http://127.0.0.1:4333`, with the expectation that the downstream RP will handle the request further, then the request ends up with `Host: 127.0.0.1` as a header, which is incorrect. It's seemingly impossible to override this behavior. Removing the setting of the Host header to fix this, as it's not necessary anyway. --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ef33424..1a2d3b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ #[macro_use] extern crate tracing; -use hyper::header::{HeaderMap, HeaderName, HeaderValue, HOST}; +use hyper::header::{HeaderMap, HeaderName, HeaderValue}; use hyper::http::header::{InvalidHeaderValue, ToStrError}; use hyper::http::uri::InvalidUri; use hyper::upgrade::OnUpgrade; @@ -225,9 +225,9 @@ fn create_proxied_request( debug!("Setting headers of proxied request"); - request - .headers_mut() - .insert(HOST, HeaderValue::from_str(uri.host().unwrap())?); + //request + // .headers_mut() + // .insert(HOST, HeaderValue::from_str(uri.host().unwrap())?); *request.uri_mut() = uri;