feat(matrix): Synapse + MAS on jupiter, published by neptun

Homeserver for mgaction.town (@user:mgaction.town). Synapse and the
Matrix Authentication Service share jupiter's postgres; logins are
OIDC-only through Authentik via MAS, since Element X can't use
Synapse's own SSO. neptun serves the apex .well-known delegation plus
matrix. and account. vhosts; the admin API stays tailnet-only.

Synapse's signing key is a sops secret so the federation identity
survives losing the RAID0 array. Covered by checks.matrix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 13:04:52 +02:00
co-authored by Claude Opus 5.5
parent 2719ed7707
commit 7a68716c1c
10 changed files with 461 additions and 3 deletions
+46
View File
@@ -0,0 +1,46 @@
{ config, lib, ... }:
# Public side of services/comms/matrix.nix, on neptun. User IDs are
# @user:mgaction.town; the apex only serves delegation, so federation and clients
# both land on matrix.mgaction.town:443 (no :8448, no SRV records).
let
upstream = config.homelab.matrixProxy.upstream;
in
{
options.homelab.matrixProxy.upstream = lib.mkOption {
type = lib.types.str;
default = "jupiter.orbit.sol";
};
config.services.caddy.virtualHosts = {
"mgaction.town".extraConfig = ''
header /.well-known/matrix/* Content-Type application/json
header /.well-known/matrix/client Access-Control-Allow-Origin *
respond /.well-known/matrix/server `{"m.server":"matrix.mgaction.town:443"}`
respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://matrix.mgaction.town"}}`
respond 404
'';
# /_synapse/admin and /_synapse/mas stay tailnet-only.
"matrix.mgaction.town".extraConfig = ''
request_body {
max_size 100MB
}
@mas path_regexp ^/_matrix/client/[^/]+/(login|logout|refresh)
handle @mas {
reverse_proxy http://${upstream}:8080
}
@synapse path /_matrix/* /_synapse/client/*
handle @synapse {
reverse_proxy http://${upstream}:8008
}
handle {
respond 404
}
'';
"account.mgaction.town".extraConfig = ''
reverse_proxy http://${upstream}:8080
'';
};
}