fix: bug of default_app for cleartext http
This commit is contained in:
parent
f6c4032f83
commit
5e76c2b055
3 changed files with 13 additions and 10 deletions
|
|
@ -80,15 +80,15 @@ pub fn build_settings() -> std::result::Result<(ProxyConfig, AppConfigList<Crypt
|
||||||
|
|
||||||
// let mut backends = Backends::new();
|
// let mut backends = Backends::new();
|
||||||
for (app_name, app) in apps.0.iter() {
|
for (app_name, app) in apps.0.iter() {
|
||||||
let server_name_string = app.server_name.as_ref().ok_or(anyhow!("No server name"))?;
|
let _server_name_string = app.server_name.as_ref().ok_or(anyhow!("No server name"))?;
|
||||||
let app_config = app.try_into()?;
|
let registered_app_name = app_name.to_ascii_lowercase();
|
||||||
|
let app_config = app.build_app_config(®istered_app_name)?;
|
||||||
app_config_list_inner.push(app_config);
|
app_config_list_inner.push(app_config);
|
||||||
info!("Registering application: {} ({})", app_name, server_name_string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let app_config_list = AppConfigList {
|
let app_config_list = AppConfigList {
|
||||||
inner: app_config_list_inner,
|
inner: app_config_list_inner,
|
||||||
default_app: config.default_app, // default backend application for plaintext http requests
|
default_app: config.default_app.map(|v| v.to_ascii_lowercase()), // default backend application for plaintext http requests
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((proxy_config, app_config_list))
|
Ok((proxy_config, app_config_list))
|
||||||
|
|
|
||||||
|
|
@ -168,10 +168,8 @@ impl ConfigToml {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryInto<AppConfig<CryptoFileSource>> for &Application {
|
impl Application {
|
||||||
type Error = anyhow::Error;
|
pub fn build_app_config(&self, app_name: &str) -> std::result::Result<AppConfig<CryptoFileSource>, anyhow::Error> {
|
||||||
|
|
||||||
fn try_into(self) -> std::result::Result<AppConfig<CryptoFileSource>, Self::Error> {
|
|
||||||
let server_name_string = self.server_name.as_ref().ok_or(anyhow!("Missing server_name"))?;
|
let server_name_string = self.server_name.as_ref().ok_or(anyhow!("Missing server_name"))?;
|
||||||
|
|
||||||
// reverse proxy settings
|
// reverse proxy settings
|
||||||
|
|
@ -202,6 +200,7 @@ impl TryInto<AppConfig<CryptoFileSource>> for &Application {
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(AppConfig {
|
Ok(AppConfig {
|
||||||
|
app_name: app_name.to_owned(),
|
||||||
server_name: server_name_string.to_owned(),
|
server_name: server_name_string.to_owned(),
|
||||||
reverse_proxy: reverse_proxy_config,
|
reverse_proxy: reverse_proxy_config,
|
||||||
tls: tls_config,
|
tls: tls_config,
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,10 @@ where
|
||||||
backends
|
backends
|
||||||
.apps
|
.apps
|
||||||
.insert(app_config.server_name.clone().to_server_name_vec(), backend);
|
.insert(app_config.server_name.clone().to_server_name_vec(), backend);
|
||||||
info!("Registering application: ({})", &app_config.server_name);
|
info!(
|
||||||
|
"Registering application {} ({})",
|
||||||
|
&app_config.server_name, &app_config.app_name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// default backend application for plaintext http requests
|
// default backend application for plaintext http requests
|
||||||
|
|
@ -154,6 +157,7 @@ pub struct AppConfig<T>
|
||||||
where
|
where
|
||||||
T: CryptoSource,
|
T: CryptoSource,
|
||||||
{
|
{
|
||||||
|
pub app_name: String,
|
||||||
pub server_name: String,
|
pub server_name: String,
|
||||||
pub reverse_proxy: Vec<ReverseProxyConfig>,
|
pub reverse_proxy: Vec<ReverseProxyConfig>,
|
||||||
pub tls: Option<TlsConfig<T>>,
|
pub tls: Option<TlsConfig<T>>,
|
||||||
|
|
@ -171,7 +175,7 @@ where
|
||||||
let reverse_proxy = self.try_into()?;
|
let reverse_proxy = self.try_into()?;
|
||||||
|
|
||||||
backend_builder
|
backend_builder
|
||||||
.app_name(self.server_name.clone())
|
.app_name(self.app_name.clone())
|
||||||
.server_name(self.server_name.clone())
|
.server_name(self.server_name.clone())
|
||||||
.reverse_proxy(reverse_proxy);
|
.reverse_proxy(reverse_proxy);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue