Compare commits

...

2 commits

Author SHA1 Message Date
Rustam Efimov
e77bc1e641
refactor(services/synapse): remove deadcode
Some checks failed
Nix CI / build (push) Failing after 30s
2026-04-14 21:59:39 +03:00
Rustam Efimov
d2949df2fb
feat(services/synapse): add well-known 2026-04-14 21:58:54 +03:00

View file

@ -1,7 +1,14 @@
{ config, ... }:
let
inherit (config.machine.synapse) domain port;
maxUploadSize = config.services.matrix-synapse.settings.max_upload_size;
cfg = config.machine.synapse;
clientConfig."m.homeserver".base_url = baseUrl;
serverConfig."m.server" = "${cfg.domain}:443";
mkWellKnown = data: ''
default_type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON data}';
'';
in
{
systemd.services.nginx.serviceConfig.SupplementaryGroups = [ "matrix-synapse" ];
@ -9,18 +16,16 @@ in
services.nginx = {
appendHttpConfig = ''
limit_req_zone $binary_remote_addr zone=matrix:10m rate=50r/s;
limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
'';
upstreams."matrix-synapse".servers = {
"unix:/run/matrix-synapse/matrix-synapse.sock" = { };
};
virtualHosts.${domain} = {
virtualHosts.${cfg.domain} = {
forceSSL = true;
enableACME = true;
locations = {
"= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
"= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
"^~ /_matrix" = {
proxyPass = "http://127.0.0.1:${toString port}";
proxyPass = "http://127.0.0.1:${toString cfg.port}";
extraConfig = ''
limit_req zone=matrix burst=100 nodelay;
proxy_set_header Host $host;
@ -36,7 +41,7 @@ in
# Health check
"= /health" = {
proxyPass = "http://127.0.0.1:${toString port}";
proxyPass = "http://127.0.0.1:${toString cfg.port}";
extraConfig = ''
access_log off;
'';