fix(web): make the listener bind address configurable via DBX_BIND_ADDR
This commit is contained in:
1 parent
6f5511a732
commit
9540f51dce
1 file changed
+14
-2
@@ -8,7 +8,7 @@ mod state;
|
||||
mod web_mcp;
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::net::SocketAddr;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::sync::Arc;
|
||||
|
||||
use argon2::password_hash::rand_core::OsRng;
|
||||
@@ -1398,7 +1398,19 @@ async fn serve() {
|
||||
|
||||
// Bind address
|
||||
let port: u16 = std::env::var("DBX_PORT").ok().and_then(|p| p.parse().ok()).unwrap_or(4224);
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
// Defaults to all interfaces for container deployments; operators who
|
||||
// expose the service through a local reverse proxy can pin the listener
|
||||
// (DBX_BIND_ADDR=127.0.0.1) without a firewall change. The value is an
|
||||
// IP only — the port always comes from DBX_PORT so the HTTP listener and
|
||||
// the Redis PubSub server (which reads DBX_PORT independently) stay in
|
||||
// sync.
|
||||
let ip = match std::env::var("DBX_BIND_ADDR").ok().as_deref().map(str::trim).filter(|value| !value.is_empty()) {
|
||||
Some(value) => {
|
||||
value.parse::<IpAddr>().unwrap_or_else(|error| panic!("invalid DBX_BIND_ADDR \"{value}\": {error}"))
|
||||
}
|
||||
None => IpAddr::from([0, 0, 0, 0]),
|
||||
};
|
||||
let addr = SocketAddr::new(ip, port);
|
||||
|
||||
tracing::info!("DBX Web server starting on http://{}", addr);
|
||||
if public_base_path != "/" {
|
||||
|
||||
Reference in new issue
Block a user