[core] Unix upstreams: unix:/path parses strictly into a socket upstream; edge proxies and health-checks it in plain HTTP over the socket, Caddy dials unix/<path>
This commit is contained in:
@@ -85,6 +85,8 @@ pub struct UpstreamRt {
|
||||
pub authority: String,
|
||||
pub tls: bool,
|
||||
pub sni: String,
|
||||
/// A `unix:` upstream's socket path (plain HTTP); `host` and `port` are then unused.
|
||||
pub unix: Option<String>,
|
||||
pub healthy: AtomicBool,
|
||||
pub health: HealthRecord,
|
||||
}
|
||||
@@ -205,6 +207,21 @@ fn upstream(u: &EdgeUpstream) -> Result<UpstreamRt, EdgeError> {
|
||||
address: u.address.clone(),
|
||||
reason: reason.to_owned(),
|
||||
};
|
||||
if let Some(path) = u.address.strip_prefix("unix:") {
|
||||
if !path.starts_with('/') || u.tls {
|
||||
return Err(err("expected unix:/absolute/path, plain HTTP"));
|
||||
}
|
||||
return Ok(UpstreamRt {
|
||||
host: String::new(),
|
||||
port: 0,
|
||||
authority: u.address.clone(),
|
||||
tls: false,
|
||||
sni: String::new(),
|
||||
unix: Some(path.to_owned()),
|
||||
healthy: AtomicBool::new(true),
|
||||
health: HealthRecord::default(),
|
||||
});
|
||||
}
|
||||
let (host, port) = u
|
||||
.address
|
||||
.rsplit_once(':')
|
||||
@@ -223,6 +240,7 @@ fn upstream(u: &EdgeUpstream) -> Result<UpstreamRt, EdgeError> {
|
||||
authority: u.address.clone(),
|
||||
tls: u.tls,
|
||||
sni: u.sni.clone(),
|
||||
unix: None,
|
||||
healthy: AtomicBool::new(true),
|
||||
health: HealthRecord::default(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user