diff --git a/.dev-config.yml b/.dev-config.yml index e1b0464..d54cf36 100644 --- a/.dev-config.yml +++ b/.dev-config.yml @@ -4,9 +4,9 @@ domain: store_dir_path: /tmp/domani_dev_env/domain builtins: foo: - kind: proxy + kind: http_proxy url: http://127.0.0.1:9000 - request_http_headers: + request_headers: - name: x-foo value: BAR - name: host diff --git a/README.md b/README.md index f0eeec2..69acdf8 100644 --- a/README.md +++ b/README.md @@ -63,15 +63,12 @@ domain: # kind: git # url: "https://somewhere.com/some/repo.git" # branch_name: main - # public: false # - # # Which protocols to serve the domain on. The given list overwrites the - # # default, which is to serve on all available protocols. - # #serve_protocols: - # #- protocol: http - # #- protocol: https + # # If true then the built-in will be included in the web interface's + # # domain list, but will not be configurable in the web interface + # public: false - # An example built-in domain backed by a reverse-proxy to some other + # An example built-in domain backed by an HTTP reverse-proxy to some other # web-service. Requests to the backing service will automatically have # X-Forwarded-For and (if HTTPS) X-Forwarded-Proto headers added to them. # @@ -80,23 +77,19 @@ domain: # * dns.resolver_addr is ignored and the system-wide dns is used # #proxy.example.com: - # kind: proxy + # kind: http_proxy # url: "http://some.other.service.com" # - # # Extra headers to add to requests being proxied - # request_http_headers: + # # Extra headers to add to proxied requests + # request_headers: # - name: Host # value: "yet.another.service.com" # - name: X-HEADER-TO-DELETE # value: "" # + # # If true then the built-in will be included in the web interface's + # # domain list, but will not be configurable in the web interface # public: false - # - # # Which protocols to serve the domain on. The given list overwrites the - # # default, which is to serve on all available protocols. - # #serve_protocols: - # #- protocol: http - # #- protocol: https service: diff --git a/src/domain/manager.rs b/src/domain/manager.rs index e2ce452..99d20d7 100644 --- a/src/domain/manager.rs +++ b/src/domain/manager.rs @@ -248,7 +248,7 @@ impl Manager for ManagerImpl { ) -> Result { let settings = self.domain_store.get(domain)?.settings; - if let origin::Descr::Proxy { .. } = settings.origin_descr { + if let origin::Descr::HttpProxy { .. } = settings.origin_descr { return Err(unexpected::Error::from("origin is proxy, can't serve file").into()); } diff --git a/src/main.rs b/src/main.rs index 45d82de..9be7fb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ async fn main() { } for (domain, builtin_domain) in &config.domain.builtins { - if let domani::origin::Descr::Proxy { ref url, .. } = + if let domani::origin::Descr::HttpProxy { ref url, .. } = builtin_domain.settings.origin_descr { if let Err(e) = domani::origin::proxy::validate_proxy_url(url) { diff --git a/src/origin/descr.rs b/src/origin/descr.rs index 294dfa9..a980529 100644 --- a/src/origin/descr.rs +++ b/src/origin/descr.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct DescrProxyHttpHeader { +pub struct DescrHttpProxyHeader { pub name: String, pub value: String, } @@ -15,10 +15,10 @@ pub enum Descr { #[serde(rename = "git")] Git { url: String, branch_name: String }, - #[serde(rename = "proxy")] - Proxy { + #[serde(rename = "http_proxy")] + HttpProxy { url: String, - request_http_headers: Vec, + request_headers: Vec, }, } @@ -38,13 +38,13 @@ impl Descr { h_update(url); h_update(branch_name); } - Descr::Proxy { + Descr::HttpProxy { url, - request_http_headers, + request_headers, } => { h_update("proxy"); h_update(url); - for h in request_http_headers { + for h in request_headers { h_update("header"); h_update(&h.name); h_update(&h.value); diff --git a/src/origin/proxy.rs b/src/origin/proxy.rs index 057fa4a..68fbdb3 100644 --- a/src/origin/proxy.rs +++ b/src/origin/proxy.rs @@ -30,17 +30,17 @@ pub async fn serve_http_request( mut req: hyper::Request, req_is_https: bool, ) -> unexpected::Result> { - let (url, request_http_headers) = if let origin::Descr::Proxy { + let (url, request_headers) = if let origin::Descr::HttpProxy { ref url, - ref request_http_headers, + ref request_headers, } = settings.origin_descr { - (url, request_http_headers) + (url, request_headers) } else { panic!("non-proxy domain settings passed in: {settings:?}") }; - for header in request_http_headers { + for header in request_headers { let name: HeaderName = header .name .as_str() diff --git a/src/service/http.rs b/src/service/http.rs index a81e336..e07c690 100644 --- a/src/service/http.rs +++ b/src/service/http.rs @@ -178,7 +178,7 @@ impl<'svc> Service { }; // if the domain is backed by a proxy then that is handled specially. - if let origin::Descr::Proxy { .. } = settings.origin_descr { + if let origin::Descr::HttpProxy { .. } = settings.origin_descr { return origin::proxy::serve_http_request(&settings, client_ip, req, req_is_https) .await .unwrap_or_else(|e| { diff --git a/src/service/util.rs b/src/service/util.rs index d12855c..cbf6c9f 100644 --- a/src/service/util.rs +++ b/src/service/util.rs @@ -56,7 +56,7 @@ impl TryFrom for FlatDomainSettings { res.domain_setting_origin_descr_git_url = Some(url); res.domain_setting_origin_descr_git_branch_name = Some(branch_name); } - origin::Descr::Proxy { .. } => { + origin::Descr::HttpProxy { .. } => { return Err(unexpected::Error::from( "proxy origins not supported for forms", ));