Try tailscale

This commit is contained in:
Invariantspace 2023-11-27 21:44:04 -08:00
parent aa79162e2c
commit a2e5f43a1f
17 changed files with 50 additions and 80 deletions

View file

@ -7,6 +7,7 @@
virtualHosts =
let
dn = config.constants.domain;
hsCfg = config.services.headscale;
msfqdn = config.mailserver.fqdn;
mtfqdn = "matrix.${dn}";
vaultCfg = config.services.vaultwarden.config;
@ -22,6 +23,9 @@
"m.identity_server": { "base_url": "https://${mtfqdn}" }
}`
'';
"headscale.${dn}".extraConfig = ''
reverse_proxy ${hsCfg.address}:${toString hsCfg.port}
'';
${msfqdn} = {
extraConfig = ''
file_server ${wn "acme-challenge"}/* {

View file

@ -4,10 +4,10 @@
./caddy.nix
./configuration.nix
./hardware-configuration.nix
./headscale.nix
./mailserver.nix
./network.nix
./vaultwarden.nix
./xray.nix
../../common
];
}

View file

@ -0,0 +1,18 @@
{ config, ... }:
{
services = let const = config.constants; in {
headscale = {
enable = true;
address = const.localhost;
port = 27327;
settings.server_url = "https://headscale.${const.domain}";
};
tailscale = {
enable = true;
extraUpFlags = [ "--advertise-exit-node" ];
port = 27919;
useRoutingFeatures = "both";
};
};
}

View file

@ -1,34 +1,13 @@
{ config, ... }:
let hn = config.networking.hostName; port = config.constants.port; wgi = "wgs"; in {
let hn = config.networking.hostName; in {
networking = {
domain = config.constants.domain;
firewall = {
allowedTCPPorts = with port; [ http https xray ];
allowedUDPPorts = with port; [ wireguard-server ];
allowedTCPPorts = with config.constants.port; [ http https ];
};
hostId = "2cadb253";
nat = {
enable = true;
externalInterface = "ens18";
internalInterfaces = [ wgi ];
};
nftables.enable = true;
wireguard.interfaces.${wgi} = {
ips = [ "10.32.54.76/24" ];
listenPort = port.wireguard-server;
peers = [
{
allowedIPs = [ "10.32.54.2/32" ];
publicKey = "RhS1H8g47EnOhu1F6y3QO6XqxnabGcNNb0BixBuKkDQ=";
}
{
allowedIPs = [ "10.32.54.3/32" ];
publicKey = "1OA03mqu7SxREAum4UabJKD7hf+foPLu1j0E1N5K508=";
}
];
privateKeyFile = config.sops.secrets."wireguard/${hn}".path;
};
};
services = {
@ -53,8 +32,5 @@ let hn = config.networking.hostName; port = config.constants.port; wgi = "wgs";
resolved.enable = true;
};
sops.secrets = {
"cloudflare/${hn}" = { };
"wireguard/${hn}" = { };
};
sops.secrets."cloudflare/${hn}" = { };
}

View file

@ -1,10 +0,0 @@
{ config, ... }:
let xrayCfg = "xray/config.json"; in {
services.xray = {
enable = true;
settingsFile = config.sops.secrets.${xrayCfg}.path;
};
sops.secrets.${xrayCfg}.mode = "0444";
}