[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
+4
View File
@@ -112,6 +112,8 @@ pub struct EdgeSpec<'a> {
pub files: Vec<(String, Vec<u8>)>,
/// Peers whose X-Forwarded-For edge believes.
pub trusted_proxies: Vec<std::net::IpAddr>,
/// The front proxy's Unix socket.
pub proxy_socket: Option<String>,
}
impl Default for EdgeSpec<'_> {
@@ -125,6 +127,7 @@ impl Default for EdgeSpec<'_> {
http_port: None,
files: Vec::new(),
trusted_proxies: Vec::new(),
proxy_socket: None,
}
}
}
@@ -195,6 +198,7 @@ pub fn spawn(spec: EdgeSpec<'_>) -> Edge {
caddy_admin: None,
caddy_admin_socket: None,
trusted_proxies: spec.trusted_proxies.clone(),
proxy_socket: spec.proxy_socket.clone(),
};
let config_text = compile_with(&dir, &ca, &opts, spec.site, &spec.hosts);
std::fs::write(dir.join("edge.json"), &config_text).unwrap();
+9 -5
View File
@@ -147,10 +147,14 @@ mod unix {
let echo = Echo::start("app").await;
let dir = ianitor_testkit::proc::TempDir::new("proxy-sock");
let sock = dir.join("proxy.sock");
let edge = app_edge(
&echo,
vec!["--proxy-socket".into(), sock.to_string_lossy().into()],
);
let edge = start(EdgeSpec {
hosts: vec![host_file(
"app.test",
&format!("upstreams = [\"{}\"]\n", echo.url()),
)],
proxy_socket: Some(sock.to_string_lossy().into()),
..Default::default()
});
for _ in 0..100 {
if sock.exists() {
break;
@@ -221,7 +225,7 @@ mod unix {
devices_ca.issue(&["a-device"]).cert_pem.into_bytes(),
),
],
extra_args: vec!["--proxy-socket".into(), sock.to_string_lossy().into()],
proxy_socket: Some(sock.to_string_lossy().into()),
..Default::default()
});
for _ in 0..100 {