|
|
|
@ -66,8 +66,6 @@ impl Service { |
|
|
|
|
where |
|
|
|
|
CertResolver: rustls::server::ResolvesServerCert + 'static, |
|
|
|
|
{ |
|
|
|
|
let https_enabled = config.http.https_addr.is_some(); |
|
|
|
|
|
|
|
|
|
let service = sync::Arc::new(Service { |
|
|
|
|
domain_manager: domain_manager.clone(), |
|
|
|
|
cert_resolver: sync::Arc::from(cert_resolver), |
|
|
|
@ -79,13 +77,17 @@ impl Service { |
|
|
|
|
|
|
|
|
|
task_stack.push_spawn(|canceller| tasks::listen_http(service.clone(), canceller)); |
|
|
|
|
|
|
|
|
|
if https_enabled { |
|
|
|
|
if service.https_enabled() { |
|
|
|
|
task_stack.push_spawn(|canceller| tasks::listen_https(service.clone(), canceller)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
service |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn https_enabled(&self) -> bool { |
|
|
|
|
self.config.http.https_addr.is_some() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn serve(&self, status_code: u16, path: &str, body: Body) -> Response<Body> { |
|
|
|
|
match Response::builder() |
|
|
|
|
.status(status_code) |
|
|
|
@ -125,7 +127,7 @@ impl Service { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn presenter_http_scheme(&self) -> &str { |
|
|
|
|
if self.config.http.https_addr.is_some() { |
|
|
|
|
if self.https_enabled() { |
|
|
|
|
return "https"; |
|
|
|
|
} |
|
|
|
|
"http" |
|
|
|
@ -542,7 +544,7 @@ impl Service { |
|
|
|
|
// - /.well-known urls
|
|
|
|
|
// - proxied domains with https_disabled set on them
|
|
|
|
|
// everything else must use https if possible.
|
|
|
|
|
let https_upgradable = self.config.http.https_addr.is_some() && !req_is_https; |
|
|
|
|
let https_upgradable = self.https_enabled() && !req_is_https; |
|
|
|
|
|
|
|
|
|
if let Some(config) = self.proxied_domains.get(&domain) { |
|
|
|
|
if config.http_url.is_none() { |
|
|
|
|