add x-forwarded-proto

This commit is contained in:
Jun Kurihara 2022-07-09 12:37:50 +09:00
commit 828d2300c0
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
3 changed files with 96 additions and 86 deletions

View file

@ -49,6 +49,7 @@ pub(super) fn append_header_entry(
pub(super) fn add_forwarding_header(
headers: &mut HeaderMap,
client_addr: SocketAddr,
tls: bool,
) -> Result<()> {
// default process
// optional process defined by upstream_option is applied in fn apply_upstream_options
@ -57,6 +58,11 @@ pub(super) fn add_forwarding_header(
"x-forwarded-for",
&client_addr.to_canonical().ip().to_string(),
)?;
append_header_entry(
headers,
"x-forwarded-proto",
if tls { "https" } else { "http" },
)?;
Ok(())
}