1
0
Fork 0
nixos-config/nixos/roles/mathechor.de.nix

60 lines
1.9 KiB
Nix
Raw Normal View History

2020-09-30 23:30:40 +00:00
{
2022-03-08 01:42:46 +00:00
config,
pkgs,
lib,
...
}: {
2019-08-07 21:40:26 +00:00
services = {
nginx = {
enable = true;
virtualHosts."mathechor.de" = {
2022-03-08 01:42:46 +00:00
serverAliases = ["www.mathechor.de"];
2019-08-07 21:40:26 +00:00
forceSSL = true;
enableACME = true;
locations = {
"/" = {
root = "/var/www/mathechor/public";
index = "index.html";
2022-03-08 01:42:46 +00:00
extraConfig = "location ~* .(otf)$ {add_header Access-Control-Allow-Origin *;}";
2019-08-07 21:40:26 +00:00
};
};
};
virtualHosts."intern.mathechor.de" = {
forceSSL = true;
enableACME = true;
locations = {
"/" = {
root = "/var/www/mathechor/intern";
index = "index.html";
2022-03-27 19:05:20 +00:00
extraConfig = ''
if ($query_string ~ "pw=([A-Za-z]*)") {
2022-03-27 21:37:06 +00:00
add_header Set-Cookie "password=$1; path=/; Max-Age=${toString (365 * 24 * 60 * 60)}; Secure";
2022-03-27 19:05:20 +00:00
return 303 /;
}
if ($http_cookie !~ "password=${pkgs.privateValue "" "mathechor.de-pw"}") {
return 303 /logout;
}
'';
2019-08-07 21:40:26 +00:00
};
2022-03-27 19:05:20 +00:00
"/login".extraConfig = ''
2022-04-19 10:50:32 +00:00
more_set_headers 'Content-Type: text/html';
2022-03-27 19:05:20 +00:00
return 200 '<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body><form style="text-align: center; margin: 250px auto; width: 500px;" action="/" method="get"><label for="pw">Passwort: </label><input type="password" name="pw"><input type="submit" value="login"></form></html></body>';
'';
"/logout".extraConfig = ''
add_header Set-Cookie 'password=""; Max-Age=0';
return 303 /login;
'';
2019-08-07 21:40:26 +00:00
"/mathechor.ics" = {
2020-09-30 23:30:40 +00:00
proxyPass = pkgs.privateValue "" "mathechor-ics";
2019-08-07 21:40:26 +00:00
extraConfig = ''
proxy_ssl_name cloud.mathechor.de;
proxy_ssl_server_name on;
2021-11-08 22:12:05 +00:00
set $args export;
2019-08-07 21:40:26 +00:00
'';
};
};
};
};
};
}