From e23297f695ce94c61d1fe67b1cf91f5bdbf549a7 Mon Sep 17 00:00:00 2001 From: "shiro.lee" <69624924+shiroleeee@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:49:36 +0800 Subject: [PATCH] fix: add the default port number to the given server domains (#373) (#458) --- rustfs/src/server/http.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rustfs/src/server/http.rs b/rustfs/src/server/http.rs index 76dadeac7..1ff4e67a2 100644 --- a/rustfs/src/server/http.rs +++ b/rustfs/src/server/http.rs @@ -137,8 +137,21 @@ pub async fn start_http_server( b.set_route(admin::make_admin_route(opt.console_enable)?); if !opt.server_domains.is_empty() { - info!("virtual-hosted-style requests are enabled use domain_name {:?}", &opt.server_domains); - b.set_host(MultiDomain::new(&opt.server_domains).map_err(Error::other)?); + MultiDomain::new(&opt.server_domains).map_err(Error::other)?; // validate domains + + // add the default port number to the given server domains + let mut domain_sets = std::collections::HashSet::new(); + for domain in &opt.server_domains { + domain_sets.insert(domain.to_string()); + if let Some((host, _)) = domain.split_once(':') { + domain_sets.insert(format!("{}:{}", host, server_port)); + } else { + domain_sets.insert(format!("{}:{}", domain, server_port)); + } + } + + info!("virtual-hosted-style requests are enabled use domain_name {:?}", &domain_sets); + b.set_host(MultiDomain::new(domain_sets).map_err(Error::other)?); } b.build()