90 lines
2.0 KiB
Nix
Raw Normal View History

2024-06-30 13:51:39 +03:00
{ config, ... }:
2024-01-18 21:46:51 +03:00
let
2024-03-04 00:00:27 +03:00
cert-fqdn = "ataraxiadev.com";
2024-01-18 21:46:51 +03:00
in {
virtualisation.libvirt.guests.debian-matrix = {
autoStart = true;
user = config.mainuser;
group = "libvirtd";
2024-03-04 00:00:27 +03:00
xmlFile = ./vm.xml;
2024-01-18 21:46:51 +03:00
};
networking = let
libvirt-ifname = "virbr0";
guest-ip = "192.168.122.11";
synapse-ports = [ 8081 8448 8766 ];
in {
2024-06-30 13:51:39 +03:00
firewall.allowedTCPPorts = synapse-ports;
2024-01-18 21:46:51 +03:00
nat = {
enable = true;
2024-03-04 00:00:27 +03:00
internalInterfaces = [ "br0" ];
2024-01-18 21:46:51 +03:00
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";
}];
};
};
2024-03-04 00:00:27 +03:00
services.nginx.virtualHosts = let
proxySettings = ''
2024-04-23 21:37:21 +03:00
client_max_body_size 50M;
2024-03-04 00:00:27 +03:00
proxy_set_header Host $host;
2024-04-23 21:37:21 +03:00
proxy_set_header X-Forwarded-For $remote_addr;
2024-03-04 00:00:27 +03:00
proxy_set_header X-Forwarded-Proto $scheme;
'';
default = {
useACMEHost = cert-fqdn;
enableACME = false;
forceSSL = true;
};
in {
"matrix:443" = {
serverAliases = [
"matrix.ataraxiadev.com"
"element.ataraxiadev.com"
];
listen = [{
addr = "0.0.0.0";
port = 443;
ssl = true;
2024-04-23 21:37:21 +03:00
} {
addr = "[::]";
port = 443;
ssl = true;
2024-03-04 00:00:27 +03:00
}];
locations."/" = {
proxyPass = "http://192.168.122.11:8081";
extraConfig = ''
2024-04-23 21:37:21 +03:00
proxy_set_header X-Real-IP $remote_addr;
2024-03-04 00:00:27 +03:00
'' + proxySettings;
};
} // default;
"matrix:8448" = {
serverAliases = [ "matrix.ataraxiadev.com" ];
listen = [{
addr = "0.0.0.0";
port = 8448;
ssl = true;
2024-04-23 21:37:21 +03:00
} {
addr = "[::]";
port = 8448;
ssl = true;
2024-03-04 00:00:27 +03:00
}];
locations."/" = {
proxyPass = "http://192.168.122.11:8448";
2024-04-23 21:37:21 +03:00
extraConfig = proxySettings;
2024-03-04 00:00:27 +03:00
};
} // default;
};
2024-01-18 21:46:51 +03:00
}