Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ferron/src/optional_modules/rproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl ServerModuleHandlers for ReverseProxyModuleHandlers {
let disable_certificate_verification = config["disableProxyCertificateVerification"]
.as_bool()
.unwrap_or(false);
let set_host_header = config["proxyHostHeader"].as_bool().unwrap_or(false);
let proxy_intercept_errors = config["proxyInterceptErrors"].as_bool().unwrap_or(false);
if let Some(proxy_to) = determine_proxy_to(
config,
Expand Down Expand Up @@ -245,7 +246,10 @@ impl ServerModuleHandlers for ReverseProxyModuleHandlers {
if let Some(original_host) = original_host {
hyper_request_parts
.headers
.insert("x-forwarded-host", original_host);
.insert("x-forwarded-host", original_host.clone());
if set_host_header {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code - Priority: High

  • The logic for handling set_host_header appears to be duplicated within the file or across other files. Consider refactoring this logic into a reusable function to improve maintainability.

hyper_request_parts.headers.insert("Host", original_host);
}
}

let proxy_request = Request::from_parts(hyper_request_parts, request_body);
Expand Down