[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:
@@ -60,10 +60,6 @@ pub struct Options {
|
||||
pub credentials_dir: Option<PathBuf>,
|
||||
/// The overall deadline for a request header; default [`deadline::HEADER_TIMEOUT`].
|
||||
pub header_timeout: Option<std::time::Duration>,
|
||||
/// A Unix socket (mode 0660) on which edge 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 `X-Forwarded-For` is believed (Unix only).
|
||||
pub proxy_socket: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
@@ -148,8 +144,8 @@ pub fn server(shared: Arc<Shared>, opts: &Options) -> Result<Server, EdgeError>
|
||||
https
|
||||
.endpoints()
|
||||
.set_pre_tls_callback(Arc::new(tls::HandshakeStart));
|
||||
if let Some(path) = &opts.proxy_socket {
|
||||
add_proxy_socket(&mut https, path)?;
|
||||
if let Some(path) = &rt.cfg.proxy_socket {
|
||||
add_proxy_socket(&mut https, Path::new(path))?;
|
||||
}
|
||||
|
||||
let mut http = Service::new(
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
//! `ianitor-edge --config <edge.json> [--check] [--admin-socket <path>] [--trial-config <path>]
|
||||
//! [--share-revocations <path>] [--acme-root <ca.pem>] [--header-timeout <secs>]
|
||||
//! [--proxy-socket <path>]`
|
||||
//! [--share-revocations <path>] [--acme-root <ca.pem>] [--header-timeout <secs>]`
|
||||
//!
|
||||
//! Secrets come from `$CREDENTIALS_DIRECTORY`; the log level from `$IANITOR_LOG`
|
||||
//! (error, warn, info, debug, trace; libraries are capped at info).
|
||||
@@ -24,7 +23,6 @@ fn parse_args() -> Result<(Options, bool), EdgeError> {
|
||||
Some("--config") => config = args.next().map(PathBuf::from),
|
||||
Some("--acme-root") => opts.acme_root = args.next().map(PathBuf::from),
|
||||
Some("--admin-socket") => opts.admin_socket = args.next().map(PathBuf::from),
|
||||
Some("--proxy-socket") => opts.proxy_socket = args.next().map(PathBuf::from),
|
||||
Some("--trial-config") => opts.trial_config = args.next().map(PathBuf::from),
|
||||
Some("--share-revocations") => opts.share_revocations = args.next().map(PathBuf::from),
|
||||
Some("--header-timeout") => {
|
||||
@@ -42,7 +40,7 @@ fn parse_args() -> Result<(Options, bool), EdgeError> {
|
||||
println!(
|
||||
"usage: ianitor-edge --config <edge.json> [--check] [--admin-socket <path>] \
|
||||
[--trial-config <path>] [--share-revocations <path>] [--acme-root <ca.pem>] \
|
||||
[--header-timeout <secs>] [--proxy-socket <path>]"
|
||||
[--header-timeout <secs>]"
|
||||
);
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,10 @@ pub struct Shared {
|
||||
}
|
||||
|
||||
fn same_listeners(a: &Runtime, b: &Runtime) -> Result<(), EdgeError> {
|
||||
if a.cfg.http_listen != b.cfg.http_listen || a.cfg.https_listen != b.cfg.https_listen {
|
||||
if a.cfg.http_listen != b.cfg.http_listen
|
||||
|| a.cfg.https_listen != b.cfg.https_listen
|
||||
|| a.cfg.proxy_socket != b.cfg.proxy_socket
|
||||
{
|
||||
return Err(EdgeError::Config {
|
||||
path: PathBuf::from("<new config>"),
|
||||
message: "the listen addresses can only change with a restart".into(),
|
||||
|
||||
Reference in New Issue
Block a user