use tailscale auth for hledger
This commit is contained in:
@@ -36,7 +36,8 @@ in
|
|||||||
networking.useDHCP = false;
|
networking.useDHCP = false;
|
||||||
networking.nftables.enable = true;
|
networking.nftables.enable = true;
|
||||||
|
|
||||||
services.octodns.records."" = {
|
services.octodns.records = {
|
||||||
|
"" = {
|
||||||
A = {
|
A = {
|
||||||
ttl = 86400;
|
ttl = 86400;
|
||||||
values = [ ipv4Address ];
|
values = [ ipv4Address ];
|
||||||
@@ -46,6 +47,17 @@ in
|
|||||||
values = [ ipv6Address ];
|
values = [ ipv6Address ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
"ts" = {
|
||||||
|
A = {
|
||||||
|
ttl = 86400;
|
||||||
|
values = [ "100.84.105.63" ];
|
||||||
|
};
|
||||||
|
AAAA = {
|
||||||
|
ttl = 86400;
|
||||||
|
values = [ "fd7a:115c:a1e0::7901:693f" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
systemd.network = {
|
systemd.network = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
"mosquitto/mokkimaatti"
|
"mosquitto/mokkimaatti"
|
||||||
"gitlab-runner/default"
|
"gitlab-runner/default"
|
||||||
"gitlab-runner/docker"
|
"gitlab-runner/docker"
|
||||||
|
"hetzner"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
// {
|
// {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ in
|
|||||||
{
|
{
|
||||||
virtualisation.podman.enable = true;
|
virtualisation.podman.enable = true;
|
||||||
virtualisation.oci-containers.backend = "podman";
|
virtualisation.oci-containers.backend = "podman";
|
||||||
|
security.acme.defaults.environmentFile = secrets.hetzner.path;
|
||||||
|
|
||||||
modules.storageBoxMounts = {
|
modules.storageBoxMounts = {
|
||||||
${immichDataDir} = {
|
${immichDataDir} = {
|
||||||
@@ -387,12 +388,17 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
subdomain = "ledger";
|
subdomain = "ledger";
|
||||||
stateDir = "${syncthingDataDir}/ledger";
|
stateDir = "${syncthingDataDir}/ledger";
|
||||||
basicAuthFile = secrets.hledger-basic-auth.path;
|
|
||||||
user = config.systemd.services.syncthing.serviceConfig.User;
|
user = config.systemd.services.syncthing.serviceConfig.User;
|
||||||
group = config.systemd.services.syncthing.serviceConfig.Group;
|
group = config.systemd.services.syncthing.serviceConfig.Group;
|
||||||
|
extraOptions = [ "--forecast" ];
|
||||||
journalFiles = [
|
journalFiles = [
|
||||||
"main.ldg"
|
"main.ldg"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
webserver = {
|
||||||
|
acme.dnsChallenge = true;
|
||||||
|
tailscaleAuth.expectedTailnet = "tempel-vibes.ts.net";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ in
|
|||||||
subdomain = lib.mkOption {
|
subdomain = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
};
|
};
|
||||||
basicAuthFile = lib.mkOption {
|
|
||||||
type = lib.types.path;
|
|
||||||
};
|
|
||||||
user = lib.mkOption {
|
user = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
};
|
};
|
||||||
@@ -24,13 +21,45 @@ in
|
|||||||
hledger-web = {
|
hledger-web = {
|
||||||
allow = lib.mkDefault "edit";
|
allow = lib.mkDefault "edit";
|
||||||
baseUrl = "https://${fqdn}";
|
baseUrl = "https://${fqdn}";
|
||||||
|
serveApi = true;
|
||||||
|
extraOptions = [
|
||||||
|
"--exchange=€"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
webserver = {
|
webserver = {
|
||||||
enable = lib.mkDefault true;
|
enable = lib.mkDefault true;
|
||||||
vHosts.${fqdn}.locations."/" = {
|
vHosts.${fqdn} = {
|
||||||
|
tailscaleAuth = true;
|
||||||
|
extraConfig = ''
|
||||||
|
root /var/www/ledgio;
|
||||||
|
add_header Access-Control-Allow-Origin $http_origin always;
|
||||||
|
add_header Access-Control-Allow-Methods 'OPTIONS, GET, PUT' always;
|
||||||
|
add_header Access-Control-Allow-Headers 'Content-Type' always;
|
||||||
|
|
||||||
|
location ~ \.(html|js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
|
try_files $uri =404;
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
locations = {
|
||||||
|
"@api" = {
|
||||||
proxyPort = cfg.port;
|
proxyPort = cfg.port;
|
||||||
basicAuthFile = cfg.basicAuthFile;
|
};
|
||||||
|
|
||||||
|
"/".extraConfig = ''
|
||||||
|
if ($request_method = OPTIONS) {
|
||||||
|
add_header Content-Type text/plain;
|
||||||
|
add_header Content-Length 0;
|
||||||
|
add_header Access-Control-Allow-Origin $http_origin;
|
||||||
|
add_header Access-Control-Allow-Methods 'OPTIONS, GET, PUT';
|
||||||
|
add_header Access-Control-Allow-Headers 'Content-Type';
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
|
||||||
|
try_files $uri $uri/ @api;
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ let
|
|||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
|
extraConfig = lib.mkOption {
|
||||||
|
type = lib.types.lines;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -59,6 +63,10 @@ in
|
|||||||
type = lib.types.attrsOf types.vhost;
|
type = lib.types.attrsOf types.vhost;
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
|
tailscaleAuth.expectedTailnet = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
@@ -75,11 +83,17 @@ in
|
|||||||
tailscaleAuth = {
|
tailscaleAuth = {
|
||||||
enable = (lib.length tailscaleAuthVhosts) > 0;
|
enable = (lib.length tailscaleAuthVhosts) > 0;
|
||||||
virtualHosts = tailscaleAuthVhosts;
|
virtualHosts = tailscaleAuthVhosts;
|
||||||
|
expectedTailnet = cfg.tailscaleAuth.expectedTailnet;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualHosts = lib.mapAttrs (
|
virtualHosts = lib.mapAttrs (
|
||||||
_:
|
_:
|
||||||
{ proxyBuffering, locations, ... }:
|
{
|
||||||
|
proxyBuffering,
|
||||||
|
locations,
|
||||||
|
extraConfig,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
@@ -88,6 +102,7 @@ in
|
|||||||
extraConfig = lib.concatLines [
|
extraConfig = lib.concatLines [
|
||||||
(lib.optionalString (!proxyBuffering) "proxy_buffering off;")
|
(lib.optionalString (!proxyBuffering) "proxy_buffering off;")
|
||||||
"charset utf-8;"
|
"charset utf-8;"
|
||||||
|
extraConfig
|
||||||
];
|
];
|
||||||
locations = lib.mapAttrs (
|
locations = lib.mapAttrs (
|
||||||
_:
|
_:
|
||||||
@@ -115,12 +130,17 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
octodns.records = lib.filterAttrs (name: _: name != config.networking.domain) (
|
octodns.records = lib.filterAttrs (name: _: name != config.networking.domain) (
|
||||||
lib.mapAttrs' (fqdn: _: {
|
lib.mapAttrs' (
|
||||||
|
fqdn:
|
||||||
|
{ tailscaleAuth, ... }:
|
||||||
|
{
|
||||||
name = lib.removeSuffix ".${config.networking.domain}" fqdn;
|
name = lib.removeSuffix ".${config.networking.domain}" fqdn;
|
||||||
value = {
|
value = {
|
||||||
CNAME.toRoot = true;
|
CNAME =
|
||||||
|
if tailscaleAuth then { target = "ts.${config.networking.domain}."; } else { toRoot = true; };
|
||||||
};
|
};
|
||||||
}) cfg.vHosts
|
}
|
||||||
|
) cfg.vHosts
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ in
|
|||||||
"mosquitto/mokkimaatti.age".publicKeys = users ++ [ freun-dev ];
|
"mosquitto/mokkimaatti.age".publicKeys = users ++ [ freun-dev ];
|
||||||
"gitlab-runner/default.age".publicKeys = users ++ [ freun-dev ];
|
"gitlab-runner/default.age".publicKeys = users ++ [ freun-dev ];
|
||||||
"gitlab-runner/docker.age".publicKeys = users ++ [ freun-dev ];
|
"gitlab-runner/docker.age".publicKeys = users ++ [ freun-dev ];
|
||||||
"hetzner.age".publicKeys = users ++ [ apu ];
|
"hetzner.age".publicKeys = users ++ [
|
||||||
|
apu
|
||||||
|
freun-dev
|
||||||
|
];
|
||||||
"hledger-basic-auth.age".publicKeys = users ++ [ freun-dev ];
|
"hledger-basic-auth.age".publicKeys = users ++ [ freun-dev ];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user