server: fix Host header (#20843)

It should include port when it's not default.
This commit is contained in:
Evgeny Kurnevsky
2026-03-22 22:29:22 +08:00
committed by GitHub
parent f40a80b4f3
commit 81bc4d3ddc
+2 -1
View File
@@ -1181,7 +1181,8 @@ server_http_proxy::server_http_proxy(
continue; continue;
} }
if (key == "Host" || key == "host") { if (key == "Host" || key == "host") {
req.set_header(key, host); bool is_default_port = (scheme == "https" && port == 443) || (scheme == "http" && port == 80);
req.set_header(key, is_default_port ? host : host + ":" + std::to_string(port));
} else { } else {
req.set_header(key, value); req.set_header(key, value);
} }