diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index 701ee5f5..663dd03e 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -42,8 +42,8 @@ pub struct Opt { #[arg(long, default_value_t = format!("0.0.0.0:{}", DEFAULT_PORT), env = "RUSTFS_ADDRESS")] pub address: String, - #[arg(long, default_value_t = format!("http://localhost:{}", DEFAULT_PORT), env = "RUSTFS_SERVER_ENDPOINT")] - pub server_endpoint: String, + #[arg(long, env = "RUSTFS_SERVER_DOMAINS")] + pub server_domains: Vec, /// Access key used for authentication. #[arg(long, default_value_t = DEFAULT_ACCESS_KEY.to_string(), env = "RUSTFS_ACCESS_KEY")] diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index d2d5ef50..cfa1a978 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -29,7 +29,7 @@ use hyper_util::{ }; use iam::init_iam_sys; use protos::proto_gen::node_service::node_service_server::NodeServiceServer; -use s3s::service::S3ServiceBuilder; +use s3s::{host::MultiDomain, service::S3ServiceBuilder}; use service::hybrid; use std::{io::IsTerminal, net::SocketAddr}; use tokio::net::TcpListener; @@ -137,6 +137,11 @@ async fn run(opt: config::Opt) -> Result<()> { b.set_route(admin::make_admin_route()?); + 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)?); + } + // // Enable parsing virtual-hosted-style requests // if let Some(dm) = opt.domain_name { // info!("virtual-hosted-style requests are enabled use domain_name {}", &dm); @@ -234,7 +239,13 @@ async fn run(opt: config::Opt) -> Result<()> { if opt.console_enable { info!("console is enabled"); tokio::spawn(async move { - console::start_static_file_server(&opt.console_address, &opt.server_endpoint).await; + let ep = if !opt.server_domains.is_empty() { + format!("http://{}", opt.server_domains[0].clone()) + } else { + format!("http://127.0.0.1:{}", server_port) + }; + + console::start_static_file_server(&opt.console_address, &ep).await; }); } diff --git a/scripts/run.sh b/scripts/run.sh index 3554e0c2..f8587071 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -24,7 +24,7 @@ export RUSTFS_VOLUMES="./target/volume/test" export RUSTFS_ADDRESS="0.0.0.0:9000" export RUSTFS_CONSOLE_ENABLE=true export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" -export RUSTFS_SERVER_ENDPOINT="http://localhost:9000" +# export RUSTFS_SERVER_DOMAINS="localhost:9000" if [ -n "$1" ]; then export RUSTFS_VOLUMES="$1"