From 49fcca592fc83ec5e8da556132188f423ca38ec7 Mon Sep 17 00:00:00 2001 From: "Herman J. Radtke III" Date: Sun, 11 Feb 2024 08:56:24 -0500 Subject: [PATCH] fix: allow mgmt api to use tls --- crates/proxy/src/main.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/crates/proxy/src/main.rs b/crates/proxy/src/main.rs index 9198917..b2b4e18 100644 --- a/crates/proxy/src/main.rs +++ b/crates/proxy/src/main.rs @@ -31,16 +31,6 @@ async fn main() -> Result<()> { let mgmt_listener = config.management.listen.parse()?; let ingest_listener = config.proxy.listen.parse()?; - tokio::spawn(async move { - tracing::info!("management API listening on {}", mgmt_listener); - if let Err(err) = axum_server::bind(mgmt_listener) - .serve(mgmt.into_make_service()) - .await - { - eprintln!("Failed to start management API server: {}", err); - } - }); - tokio::spawn(async move { tracing::info!("starting retry queue"); retry_queue.start().await; @@ -54,6 +44,25 @@ async fn main() -> Result<()> { None }; + let mgmt_tls_config = tls_config.clone(); + tokio::spawn(async move { + tracing::info!("management API listening on {}", mgmt_listener); + if let Some(tls_config) = mgmt_tls_config { + tracing::info!("tls configured for {}", mgmt_listener); + if let Err(err) = axum_server::bind_rustls(mgmt_listener, tls_config) + .serve(mgmt.into_make_service()) + .await + { + eprintln!("Failed to start management API server: {}", err); + } + } else if let Err(err) = axum_server::bind(mgmt_listener) + .serve(mgmt.into_make_service()) + .await + { + eprintln!("Failed to start management API server: {}", err); + } + }); + tracing::info!("ingest listening on {}", ingest_listener); if let Some(tls_config) = tls_config { tracing::info!("tls configured for {}", ingest_listener);