mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 22:11:33 +01:00
Shorten the subdomains of hosted services
This commit is contained in:
parent
18bbe1fd27
commit
4db060800b
6 changed files with 50 additions and 24 deletions
|
|
@ -1,42 +1,46 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
let
|
||||||
|
serviceName = "actualbudget";
|
||||||
|
subdomain = "budget";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
sops.secrets."container/actualbudget/tailscale-auth-key" = { };
|
sops.secrets."container/${serviceName}/tailscale-auth-key" = { };
|
||||||
|
|
||||||
virtualisation.oci-containers.containers = {
|
virtualisation.oci-containers.containers = {
|
||||||
actualbudget = {
|
${serviceName} = {
|
||||||
image = "ghcr.io/actualbudget/actual-server:latest";
|
image = "ghcr.io/actualbudget/actual-server:latest";
|
||||||
volumes = [ "/data/actualbudget:/data" ];
|
volumes = [ "/data/${serviceName}:/data" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
tailscale-actualbudget =
|
"tailscale-${serviceName}" =
|
||||||
let
|
let
|
||||||
configPath = pkgs.writeTextFile {
|
configPath = pkgs.writeTextFile {
|
||||||
name = "config";
|
name = "config";
|
||||||
destination = "/tailscale-serve.json";
|
destination = "/tailscale-serve.json";
|
||||||
text = builtins.toJSON {
|
text = builtins.toJSON {
|
||||||
TCP."443".HTTPS = true;
|
TCP."443".HTTPS = true;
|
||||||
Web."actualbudget.${config.networking.domain}:443".Handlers."/".Proxy = "http://127.0.0.1:5006";
|
Web."${subdomain}.${config.networking.domain}:443".Handlers."/".Proxy = "http://127.0.0.1:5006";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
image = "ghcr.io/tailscale/tailscale:latest";
|
image = "ghcr.io/tailscale/tailscale:latest";
|
||||||
environment = {
|
environment = {
|
||||||
TS_HOSTNAME = "actualbudget";
|
TS_HOSTNAME = subdomain;
|
||||||
TS_STATE_DIR = "/var/lib/tailscale";
|
TS_STATE_DIR = "/var/lib/tailscale";
|
||||||
TS_SERVE_CONFIG = "/config/tailscale-serve.json";
|
TS_SERVE_CONFIG = "/config/tailscale-serve.json";
|
||||||
TS_USERSPACE = "true"; # https://github.com/tailscale/tailscale/issues/11372
|
TS_USERSPACE = "true"; # https://github.com/tailscale/tailscale/issues/11372
|
||||||
};
|
};
|
||||||
environmentFiles = [
|
environmentFiles = [
|
||||||
# Contains "TS_AUTHKEY=<token>"
|
# Contains "TS_AUTHKEY=<token>"
|
||||||
config.sops.secrets."container/actualbudget/tailscale-auth-key".path
|
config.sops.secrets."container/${serviceName}/tailscale-auth-key".path
|
||||||
];
|
];
|
||||||
volumes = [
|
volumes = [
|
||||||
"/var/lib/tailscale-actualbudget:/var/lib/tailscale"
|
"/var/lib/tailscale-${serviceName}:/var/lib/tailscale"
|
||||||
"${configPath}:/config"
|
"${configPath}:/config"
|
||||||
];
|
];
|
||||||
extraOptions = [ "--network=container:actualbudget" ];
|
extraOptions = [ "--network=container:${serviceName}" ];
|
||||||
dependsOn = [ "actualbudget" ];
|
dependsOn = [ serviceName ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,52 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
let
|
||||||
|
serviceName = "onlyoffice";
|
||||||
|
subdomain = "office";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
sops.secrets = {
|
sops.secrets = {
|
||||||
"container/onlyoffice/tailscale-auth-key" = { };
|
"container/${serviceName}/tailscale-auth-key" = { };
|
||||||
"container/onlyoffice/jwt-secret" = { };
|
"container/${serviceName}/jwt-secret" = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualisation.oci-containers.containers = {
|
virtualisation.oci-containers.containers = {
|
||||||
onlyoffice = {
|
${serviceName} = {
|
||||||
image = "onlyoffice/documentserver";
|
image = "onlyoffice/documentserver";
|
||||||
environmentFiles = [
|
environmentFiles = [
|
||||||
# Contains "JWT_SECRET=<token>"
|
# Contains "JWT_SECRET=<token>"
|
||||||
config.sops.secrets."container/onlyoffice/jwt-secret".path
|
config.sops.secrets."container/${serviceName}/jwt-secret".path
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
tailscale-onlyoffice =
|
"tailscale-${serviceName}" =
|
||||||
let
|
let
|
||||||
configPath = pkgs.writeTextFile {
|
configPath = pkgs.writeTextFile {
|
||||||
name = "config";
|
name = "config";
|
||||||
destination = "/tailscale-serve.json";
|
destination = "/tailscale-serve.json";
|
||||||
text = builtins.toJSON {
|
text = builtins.toJSON {
|
||||||
TCP."443".HTTPS = true;
|
TCP."443".HTTPS = true;
|
||||||
Web."onlyoffice.${config.networking.domain}:443".Handlers."/".Proxy = "http://127.0.0.1:80";
|
Web."${subdomain}.${config.networking.domain}:443".Handlers."/".Proxy = "http://127.0.0.1:80";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
image = "ghcr.io/tailscale/tailscale:latest";
|
image = "ghcr.io/tailscale/tailscale:latest";
|
||||||
environment = {
|
environment = {
|
||||||
TS_HOSTNAME = "onlyoffice";
|
TS_HOSTNAME = subdomain;
|
||||||
TS_STATE_DIR = "/var/lib/tailscale";
|
TS_STATE_DIR = "/var/lib/tailscale";
|
||||||
TS_SERVE_CONFIG = "/config/tailscale-serve.json";
|
TS_SERVE_CONFIG = "/config/tailscale-serve.json";
|
||||||
TS_USERSPACE = "true"; # https://github.com/tailscale/tailscale/issues/11372
|
TS_USERSPACE = "true"; # https://github.com/tailscale/tailscale/issues/11372
|
||||||
};
|
};
|
||||||
environmentFiles = [
|
environmentFiles = [
|
||||||
# Contains "TS_AUTHKEY=<token>"
|
# Contains "TS_AUTHKEY=<token>"
|
||||||
config.sops.secrets."container/onlyoffice/tailscale-auth-key".path
|
config.sops.secrets."container/${serviceName}/tailscale-auth-key".path
|
||||||
];
|
];
|
||||||
volumes = [
|
volumes = [
|
||||||
"/var/lib/tailscale-onlyoffice:/var/lib/tailscale"
|
"/var/lib/tailscale-${serviceName}:/var/lib/tailscale"
|
||||||
"${configPath}:/config"
|
"${configPath}:/config"
|
||||||
];
|
];
|
||||||
extraOptions = [ "--network=container:onlyoffice" ];
|
extraOptions = [ "--network=container:${serviceName}" ];
|
||||||
dependsOn = [ "onlyoffice" ];
|
dependsOn = [ serviceName ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@
|
||||||
$create --admin --email "sebastian.stork@pm.me" --username seb --password "$(cat ${config.sops.secrets.forgejo-admin-password.path})" || true
|
$create --admin --email "sebastian.stork@pm.me" --username seb --password "$(cat ${config.sops.secrets.forgejo-admin-password.path})" || true
|
||||||
'';
|
'';
|
||||||
|
|
||||||
myConfig.tailscale.serve = "3000";
|
myConfig.tailscale = {
|
||||||
|
subdomain = "git";
|
||||||
|
serve = "3000";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
let
|
||||||
|
subdomain = "cloud";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
containers.nextcloud.config =
|
containers.nextcloud.config =
|
||||||
{
|
{
|
||||||
|
|
@ -41,6 +44,7 @@
|
||||||
https = true;
|
https = true;
|
||||||
settings = {
|
settings = {
|
||||||
overwriteProtocol = "https";
|
overwriteProtocol = "https";
|
||||||
|
trusted_domains = [ "${subdomain}.${config.networking.domain}" ];
|
||||||
trusted_proxies = [ "127.0.0.1" ];
|
trusted_proxies = [ "127.0.0.1" ];
|
||||||
log_type = "file";
|
log_type = "file";
|
||||||
default_phone_region = "DE";
|
default_phone_region = "DE";
|
||||||
|
|
@ -87,6 +91,9 @@
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.ffmpeg ];
|
environment.systemPackages = [ pkgs.ffmpeg ];
|
||||||
|
|
||||||
myConfig.tailscale.serve = "80";
|
myConfig.tailscale = {
|
||||||
|
inherit subdomain;
|
||||||
|
serve = "80";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@
|
||||||
settings.PAPERLESS_OCR_LANGUAGE = "deu+eng";
|
settings.PAPERLESS_OCR_LANGUAGE = "deu+eng";
|
||||||
};
|
};
|
||||||
|
|
||||||
myConfig.tailscale.serve = "28981";
|
myConfig.tailscale = {
|
||||||
|
subdomain = "paper";
|
||||||
|
serve = "28981";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@ in
|
||||||
{
|
{
|
||||||
options.myConfig.tailscale = {
|
options.myConfig.tailscale = {
|
||||||
enable = lib.mkEnableOption "";
|
enable = lib.mkEnableOption "";
|
||||||
|
subdomain = lib.mkOption {
|
||||||
|
type = lib.types.nonEmptyStr;
|
||||||
|
default = config.networking.hostName;
|
||||||
|
};
|
||||||
ssh.enable = lib.mkEnableOption "";
|
ssh.enable = lib.mkEnableOption "";
|
||||||
exitNode.enable = lib.mkEnableOption "";
|
exitNode.enable = lib.mkEnableOption "";
|
||||||
serve = lib.mkOption {
|
serve = lib.mkOption {
|
||||||
|
|
@ -28,6 +32,7 @@ in
|
||||||
useRoutingFeatures = if (cfg.exitNode.enable || (cfg.serve != null)) then "server" else "client";
|
useRoutingFeatures = if (cfg.exitNode.enable || (cfg.serve != null)) then "server" else "client";
|
||||||
extraUpFlags = [ "--reset=true" ];
|
extraUpFlags = [ "--reset=true" ];
|
||||||
extraSetFlags = [
|
extraSetFlags = [
|
||||||
|
"--hostname=${cfg.subdomain}"
|
||||||
"--ssh=${lib.boolToString cfg.ssh.enable}"
|
"--ssh=${lib.boolToString cfg.ssh.enable}"
|
||||||
"--advertise-exit-node=${lib.boolToString cfg.exitNode.enable}"
|
"--advertise-exit-node=${lib.boolToString cfg.exitNode.enable}"
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue