You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.4 KiB
65 lines
1.4 KiB
mod server;
|
|
pub use server::*;
|
|
|
|
use std::path::Path;
|
|
pub fn acme_challenges_snippet<P: AsRef<Path>>(path: P) -> String {
|
|
format!(
|
|
"location ^~ /.well-known/acme-challenge/ {{
|
|
alias {}/;
|
|
try_files $uri =404;
|
|
}}",
|
|
path.as_ref().to_str().unwrap()
|
|
)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test {
|
|
use super::{server_config, uwsgi_snippet};
|
|
|
|
#[test]
|
|
fn test_uwsgi() {
|
|
assert_eq!(
|
|
server_config(
|
|
"testdomain",
|
|
"/certpath",
|
|
"/keypath",
|
|
uwsgi_snippet("/uwsgi.sock", "/static"),
|
|
"/challenges_snippet.conf"
|
|
),
|
|
"server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name testdomain;
|
|
include \"/challenges_snippet.conf\";
|
|
|
|
ssl_certificate /certpath;
|
|
ssl_certificate_key /keypath;
|
|
add_header Strict-Transport-Security \"max-age=31536000\";
|
|
|
|
root /static;
|
|
|
|
location / {
|
|
try_files $uri @proxy;
|
|
}
|
|
|
|
location @proxy {
|
|
include uwsgi_params;
|
|
uwsgi_pass unix:/uwsgi.sock;
|
|
}
|
|
}
|
|
|
|
# Redirect all HTTP links to the matching HTTPS page
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name testdomain;
|
|
include \"/challenges_snippet.conf\";
|
|
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
"
|
|
);
|
|
}
|
|
}
|