fix bug for default app

This commit is contained in:
Jun Kurihara 2022-06-28 15:01:28 -04:00
commit 6466e7a309
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
2 changed files with 11 additions and 5 deletions

View file

@ -1,5 +1,5 @@
listen_port = 8080
listen_port_tls = 8443
# listen_port_tls = 8443
listen_ipv6 = false
max_concurrent_streams = 128

View file

@ -128,13 +128,19 @@ pub fn parse_opts(globals: &mut Globals, backends: &mut Backends) -> Result<()>
// default backend application for plaintext http requests
if let Some(d) = config.default_app {
if backends.apps.contains_key(&d) {
let d_sn: Vec<&str> = backends
.apps
.iter()
.filter(|(_k, v)| v.app_name == d)
.map(|(_, v)| v.server_name.as_ref())
.collect();
if !d_sn.is_empty() {
info!(
"Serving plaintext http for requests to unconfigured server_name: {}.",
d
"Serving plaintext http for requests to unconfigured server_name by app {} (server_name: {}).",
d, d_sn[0]
);
backends.default_app = Some(d_sn[0].to_owned());
}
backends.default_app = Some(d);
}
Ok(())