[core] Proxy socket: compile option proxy_socket gives both engines a 0660 Unix socket for the front proxy (edge in its config, Caddy a third server with trusted_proxies_unix); listeners change only with a restart

This commit is contained in:
2026-11-10 20:59:57 +01:00
parent 4150848842
commit ffffa62999
15 changed files with 117 additions and 20 deletions
+17
View File
@@ -48,6 +48,10 @@ pub struct CompileOptions {
/// Ianitor on loopback): the share-link throttle and the access log then see the real
/// client. Empty (the default): only the connection's own address counts.
pub trusted_proxies: Vec<std::net::IpAddr>,
/// A Unix socket (mode 0660) on which the engine also serves the HTTPS hosts, in plain HTTP,
/// to a front proxy that terminated TLS (Caddy beside Ianitor). Only the socket's owner and
/// group can connect, so its peer is trusted and its `X-Forwarded-For` names the client.
pub proxy_socket: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
@@ -80,6 +84,19 @@ pub fn caddy(model: &Model, options: &CompileOptions) -> Result<String, CompileE
}
fn check_options(o: &CompileOptions) -> Result<(), CompileError> {
if let Some(s) = &o.proxy_socket {
check_path(s).map_err(|reason| CompileError::BadOption {
option: "proxy_socket",
reason,
})?;
// sun_path holds 108 bytes on Linux, the terminating NUL included.
if s.len() > 100 {
return Err(CompileError::BadOption {
option: "proxy_socket",
reason: "a socket path is at most 100 characters",
});
}
}
if let Some(s) = &o.caddy_admin_socket {
check_path(s).map_err(|reason| CompileError::BadOption {
option: "caddy_admin_socket",