authelia-nginx: chnaged how to protect websites

This commit is contained in:
eyjhb 2024-12-03 22:06:04 +01:00
parent 7cde74ce97
commit 57a5740f6f
No known key found for this signature in database
GPG key ID: 609F508E3239F920
2 changed files with 3 additions and 9 deletions

View file

@ -76,12 +76,8 @@ let
error_page 401 =302 https://${config.mine.shared.settings.authelia.domain}/?rd=$target_url; error_page 401 =302 https://${config.mine.shared.settings.authelia.domain}/?rd=$target_url;
''; '';
in { in {
# TODO: fix this mine.shared.lib.authelia.mkProtectedWebsite = websiteConfig: lib.recursiveUpdate websiteConfig {
mine.shared.lib.authelia.autheliaLocation = autheliaLocation; extraConfig = (lib.attrByPath [ "extraConfig" ] "" websiteConfig) + "\n" + "include ${autheliaLocation};";
mine.shared.lib.authelia.mkProtectedWebsite = { vhostConfig, endpoint ? "/" }: lib.recursiveUpdate vhostConfig {
extraConfig = (lib.attrByPath [ "extraConfig" ] "" vhostConfig) + "\n" + "include ${autheliaLocation};";
locations."${endpoint}" = config.mine.shared.lib.authelia.mkProtectedLocation (lib.attrByPath [ "locations" endpoint ] {} vhostConfig);
}; };
mine.shared.lib.authelia.mkProtectedLocation = vhostLocationConfig: lib.recursiveUpdate vhostLocationConfig { mine.shared.lib.authelia.mkProtectedLocation = vhostLocationConfig: lib.recursiveUpdate vhostLocationConfig {

View file

@ -18,9 +18,7 @@ in {
}; };
services.nginx.virtualHosts."${config.mine.shared.settings.domain}" = config.mine.shared.lib.authelia.mkProtectedWebsite { services.nginx.virtualHosts."${config.mine.shared.settings.domain}" = config.mine.shared.lib.authelia.mkProtectedWebsite {
endpoint = urlpath; locations."${urlpath}" = config.mine.shared.lib.authelia.mkProtectedLocation {
vhostConfig.locations."${urlpath}" = {
# extraConfig = "rewrite ^${urlpath}(.*)$ /$1 break;";
proxyPass = "http://localhost:${builtins.toString port}"; proxyPass = "http://localhost:${builtins.toString port}";
}; };
}; };