整理 photoprism

This commit is contained in:
2023-11-09 20:43:25 +08:00
parent 855d24c1ea
commit ebc8f80476
3 changed files with 28 additions and 54 deletions

View File

@@ -289,12 +289,15 @@
"xlog.chn.moe" = { upstream = "cname.xlog.app:443"; rewriteHttps = true; };
"xn--qbtm095lrg0bfka60z.chn.moe" =
{ upstream.address = "internal.pc.chn.moe"; proxyProtocol = true; rewriteHttps = true; };
"xn--s8w913fdga.chn.moe" =
{ upstream.address = "internal.vps7.chn.moe"; proxyProtocol = true; rewriteHttps = true; };
"misskey.chn.moe" =
{ upstream.address = "internal.vps7.chn.moe"; proxyProtocol = true; rewriteHttps = true; };
"nextcloud.chn.moe" =
{ upstream.address = "internal.vps7.chn.moe"; proxyProtocol = true; rewriteHttps = true; };
}
// (builtins.listToAttrs (builtins.map
(site:
{
name = "${site}.chn.moe";
value =
{ upstream.address = "internal.vps7.chn.moe"; proxyProtocol = true; rewriteHttps = true; };
})
[ "xn--s8w913fdga" "misskey" "nextcloud" "photoprism" ]));
};
};
applications =
@@ -302,7 +305,6 @@
synapse.instances."synapse.chn.moe".upstream.address = "internal.vps7.chn.moe";
vaultwarden = { enable = true; upstream.address = "internal.vps7.chn.moe"; };
element.instances."element.chn.moe" = {};
photoprism.instances."photoprism.chn.moe".upstream.address = "internal.vps7.chn.moe";
synapse-admin.instances."synapse-admin.chn.moe" = {};
};
};
@@ -366,7 +368,6 @@
{
synapse.instances."synapse.chn.moe" = {};
vaultwarden.enable = true;
photoprism.instances."photoprism.chn.moe" = {};
};
};
wallabag.enable = true;

View File

@@ -1,45 +0,0 @@
inputs:
{
options.nixos.services.nginx.applications.photoprism.instances = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.attrsOf (types.submodule (submoduleInputs: { options =
{
hostname = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; };
upstream = mkOption
{
type = types.oneOf [ types.nonEmptyStr (types.submodule { options =
{
address = mkOption { type = types.nonEmptyStr; default = "127.0.0.1"; };
port = mkOption { type = types.ints.unsigned; default = 2342; };
};})];
default = "127.0.0.1:2342";
};
};}));
default = {};
};
config =
let
inherit (inputs.config.nixos.services.nginx.applications.photoprism) instances;
inherit (inputs.localLib) attrsToList;
inherit (builtins) map listToAttrs toString;
in
{
nixos.services.nginx.http = listToAttrs (map
(proxy: with proxy.value;
{
name = hostname;
value =
{
rewriteHttps = true;
locations."/".proxy =
{
upstream = if builtins.typeOf upstream == "string" then "http://${upstream}"
else "http://${upstream.address}:${toString upstream.port}";
websocket = true;
setHeaders.Host = hostname;
};
};
})
(attrsToList instances));
};
}

View File

@@ -42,6 +42,24 @@ inputs:
'';
secrets."photoprism/adminPassword" = {};
};
nixos.services.mariadb = { enable = true; instances.photoprism = {}; };
nixos.services =
{
mariadb = { enable = true; instances.photoprism = {}; };
nginx =
{
enable = true;
https.${photoprism.hostname} =
{
global.rewriteHttps = true;
listen.main.proxyProtocol = true;
location."/".proxy =
{
upstream = "http://127.0.0.1:${toString photoprism.port}";
websocket = true;
setHeaders.Host = photoprism.hostname;
};
};
};
};
};
}