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.
dont-set-host-header
Brian Picciano 4 months ago
parent e73a76600c
commit 9f4b94724f
  1. 8
      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<B>(
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;

Loading…
Cancel
Save