server-configuration/samsehu/matrix-conduit.nix

36 lines
1.3 KiB
Nix

# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, ... }:
{
# Headscale for access to the network while away from home
services.headscale.settings.dns_config.extra_records = [
{ name = "matrix.samsehu.perli.casa"; type = "A"; value = "100.64.0.3"; }
];
# configure matrix-conduit as a server to host chat communications with end-to-end encryption
services.matrix-conduit = {
enable = true;
settings.global = {
server_name = "matrix.samsehu.perli.casa";
};
};
# Reverse proxy with Caddy
services.caddy.virtualHosts."matrix.samsehu.perli.casa".extraConfig = ''
respond /.well-known/matrix/server `{ "m.server": "matrix.samsehu.perli.casa" }` 200
respond /.well-known/matrix/client `{ "m.homeserver": { "base_url": "https://matrix.samsehu.perli.casa" } }` 200
'';
services.caddy.virtualHosts."matrix.samsehu.perli.casa:8448".extraConfig = ''
reverse_proxy localhost:${toString config.services.matrix-conduit.settings.global.port}
'';
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 80 443 8448 ];
networking.firewall.allowedUDPPorts = [ 80 443 8448 ];
}