Fix acme challenges not taking priority over origins
This commit is contained in:
parent
7d4f754eec
commit
08b35f6b21
@ -330,17 +330,11 @@ where
|
|||||||
}
|
}
|
||||||
.and_then(|h| domain::Name::from_str(h).ok());
|
.and_then(|h| domain::Name::from_str(h).ok());
|
||||||
|
|
||||||
if let Some(domain) = maybe_host {
|
|
||||||
return svc.serve_origin(domain, req.uri().path());
|
|
||||||
}
|
|
||||||
|
|
||||||
let method = req.method();
|
let method = req.method();
|
||||||
let path = req.uri().path();
|
let path = req.uri().path();
|
||||||
|
|
||||||
if method == Method::GET && path.starts_with("/static/") {
|
// Serving acme challenges always takes priority. We serve them from the same store no matter
|
||||||
return svc.render(200, path, ());
|
// the domain, presumably they are cryptographically random enough that it doesn't matter.
|
||||||
}
|
|
||||||
|
|
||||||
if method == Method::GET && path.starts_with("/.well-known/acme-challenge/") {
|
if method == Method::GET && path.starts_with("/.well-known/acme-challenge/") {
|
||||||
let token = path.trim_start_matches("/.well-known/acme-challenge/");
|
let token = path.trim_start_matches("/.well-known/acme-challenge/");
|
||||||
|
|
||||||
@ -356,6 +350,17 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a managed domain was given then serve that from its origin
|
||||||
|
if let Some(domain) = maybe_host {
|
||||||
|
return svc.serve_origin(domain, req.uri().path());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serve main domiply site
|
||||||
|
|
||||||
|
if method == Method::GET && path.starts_with("/static/") {
|
||||||
|
return svc.render(200, path, ());
|
||||||
|
}
|
||||||
|
|
||||||
match (method, path) {
|
match (method, path) {
|
||||||
(&Method::GET, "/") | (&Method::GET, "/index.html") => svc.render_page("/index.html", ()),
|
(&Method::GET, "/") | (&Method::GET, "/index.html") => svc.render_page("/index.html", ()),
|
||||||
(&Method::GET, "/domain.html") => {
|
(&Method::GET, "/domain.html") => {
|
||||||
|
Loading…
Reference in New Issue
Block a user