Description
I'm trying to find out if we can host multiple subdomains from actix-web with TLS enabled. See #288.
#[tracing::instrument(skip(appstate, req))]
pub async fn handle_get_resource(
path: Option<web::Path<String>>,
appstate: web::Data<AppState>,
req: actix_web::HttpRequest,
conn: actix_web::dev::ConnectionInfo,
) -> AtomicServerResult<HttpResponse> {
let mut timer = Timer::new();
let domain = &appstate.config.opts.domain;
let host = conn.host();
let find = host.find(domain);
let subdomain = if let Some(index) = find {
if index == 0 {
None
} else {
Some(host[0..index - 1].to_string())
}
} else {
panic!("Wrong domain! A requested URL did not contain the host for this domain. This should not be able to happen.");
};
println!("subdomain: {:?}", subdomain);
let headers = req.headers();
Update: managed to read the subdomains from requests. Assuming TLS works with wildcards, what will be next? I feel like I need to think about this more, before doing any implementation.
EDIT:
We have a problem. LetsEncrypt doesn't issue wildcard certificates using HTTP-01 checks! We need a DNS check!
So for our specific case, this isn't that bad. But what about regular users who don't need subdomains? We might have to support both!
Unfortunately, doing http-01 checks with the new library I'm trying to use is a bit difficult. Maybe this changes. If it doesn't change, I suppos we should stop supporting the Http01 setup. :'(
EDIT 2:
I've added both http-01 and dns-01 setup options. Cool, right?