diff --git a/machines/Home-Hypervisor/default.nix b/machines/Home-Hypervisor/default.nix index ebc896a..dc5dc8f 100644 --- a/machines/Home-Hypervisor/default.nix +++ b/machines/Home-Hypervisor/default.nix @@ -23,7 +23,7 @@ # customProfiles.atticd # customProfiles.authentik # customProfiles.battery-historian - # customProfiles.coturn + customProfiles.coturn # customProfiles.fail2ban customProfiles.gitea # customProfiles.homepage @@ -41,7 +41,7 @@ # customProfiles.outline customProfiles.radicale # customProfiles.spdf - # customProfiles.synapse + customProfiles.synapse customProfiles.tinyproxy # customProfiles.vault customProfiles.vaultwarden diff --git a/profiles/servers/coturn.nix b/profiles/servers/coturn.nix index ae0f627..f74cca9 100644 --- a/profiles/servers/coturn.nix +++ b/profiles/servers/coturn.nix @@ -1,6 +1,6 @@ { config, lib, inputs, ... }: let - external-ip = "91.202.204.123"; + external-ip = "89.23.180.18"; coturn-denied-ips = [ "0.0.0.0-0.255.255.255" "10.0.0.0-10.255.255.255" diff --git a/profiles/servers/synapse/default.nix b/profiles/servers/synapse/default.nix index 2017992..68b5266 100644 --- a/profiles/servers/synapse/default.nix +++ b/profiles/servers/synapse/default.nix @@ -1,6 +1,7 @@ { config, ... }: let cert-fqdn = "ataraxiadev.com"; + guest-ip = "10.10.10.20"; in { virtualisation.libvirt.guests.debian-matrix = { autoStart = true; @@ -9,30 +10,9 @@ in { xmlFile = ./vm.xml; }; - networking = let - libvirt-ifname = "virbr0"; - guest-ip = "192.168.122.11"; - synapse-ports = [ 8081 8448 8766 ]; - in { - firewall.allowedTCPPorts = synapse-ports; - nat = { - enable = true; - internalInterfaces = [ "br0" ]; - externalInterface = libvirt-ifname; - forwardPorts = [{ - sourcePort = 8081; - proto = "tcp"; - destination = "${guest-ip}:8081"; - } { - sourcePort = 8448; - proto = "tcp"; - destination = "${guest-ip}:8448"; - } { - sourcePort = 8766; - proto = "tcp"; - destination = "${guest-ip}:8766"; - }]; - }; + networking.firewall = { + allowedTCPPorts = [ 443 8448 ]; + allowedUDPPorts = [ 443 8448 ]; }; services.nginx.virtualHosts = let @@ -48,6 +28,16 @@ in { forceSSL = true; }; in { + "ataraxiadev.com" = { + locations."/.well-known/matrix" = { + proxyPass = "http://${guest-ip}:8080"; + extraConfig = '' + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host matrix.$host; + ''; + }; + }; "matrix:443" = { serverAliases = [ "matrix.ataraxiadev.com" @@ -63,11 +53,25 @@ in { ssl = true; }]; locations."/" = { - proxyPass = "http://192.168.122.11:8081"; - extraConfig = '' + proxyPass = "http://${guest-ip}:8080"; + extraConfig = proxySettings + '' proxy_set_header X-Real-IP $remote_addr; - '' + proxySettings; + + # required for browsers to direct them to quic port + add_header Alt-Svc 'h3=":443"; ma=86400'; + ''; }; + locations."/synapse-admin" = { + proxyPass = "http://${guest-ip}:8080"; + extraConfig = proxySettings + '' + proxy_set_header X-Real-IP $remote_addr; + allow 10.10.10.1/24; + allow 100.64.0.1/24; + deny all; + ''; + }; + reuseport = true; + quic = true; } // default; "matrix:8448" = { serverAliases = [ "matrix.ataraxiadev.com" ]; @@ -81,9 +85,14 @@ in { ssl = true; }]; locations."/" = { - proxyPass = "http://192.168.122.11:8448"; - extraConfig = proxySettings; + proxyPass = "http://${guest-ip}:8448"; + extraConfig = proxySettings + '' + # required for browsers to direct them to quic port + add_header Alt-Svc 'h3=":8448"; ma=86400'; + ''; }; + reuseport = true; + quic = true; } // default; }; } diff --git a/profiles/servers/synapse/vm.xml b/profiles/servers/synapse/vm.xml index 4a53cdc..3006497 100644 --- a/profiles/servers/synapse/vm.xml +++ b/profiles/servers/synapse/vm.xml @@ -1,169 +1,170 @@ - + debian-matrix - 897c4bde-c3e2-476f-8ed3-acc491e40f66 + 76f37579-43b0-49b5-9145-d0c18b791b7c - 1048576 - 1048576 - 1 + 2097152 + 2097152 + 2 - hvm - + hvm + - - - - - + + + + + destroy restart destroy - - + + /run/libvirt/nix-emulators/qemu-system-x86_64 - - - - -
+ + + + +
- - - - -
+ + + + +
- - - - -
+ + + + +
- - - + + + -
+
- -
+ +
- - - - -
+ + + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- - - -
+ + + +
- -
+ +
- -
+ +
- - - - -
+ + + + +
- - - + + + - - + + - - -
+ + +
- - -