summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/auth.nix
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-08-17 10:04:28 +0200
committerRory& <root@rory.gay>2024-08-17 10:04:28 +0200
commit8fd3821f7ea8afbfb404be33df7982dbfb3b7155 (patch)
treef2cdcff78cc9b0f03883b3925f1d73fd80fac952 /host/Rory-nginx/services/matrix/synapse/workers/auth.nix
parentStart reworking other workers (diff)
downloadRory-Open-Architecture-8fd3821f7ea8afbfb404be33df7982dbfb3b7155.tar.xz
Stream writers, event creators, auth worker
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/auth.nix')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/auth.nix56
1 files changed, 30 insertions, 26 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/auth.nix b/host/Rory-nginx/services/matrix/synapse/workers/auth.nix
index 6b9e250..37cdc85 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/auth.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/auth.nix
@@ -18,6 +18,8 @@ let
       "~ ^/_matrix/client/(r0|v3|unstable)/password_policy$"
       "~ ^/_matrix/client/(r0|v3|unstable)/capabilities$"
     ];
+    federation = [ ];
+    media = [ ];
   };
 in
 {
@@ -73,38 +75,40 @@ in
       );
     };
 
-    services.nginx.upstreams."${workerName}" = {
-      extraConfig = ''
-        keepalive 32;
-      '';
-      servers = lib.listToAttrs (
-        lib.map (index: {
-          name = "unix:/run/matrix-synapse/${workerName}-client-${toString index}.sock";
+    services.nginx.upstreams = (
+      lib.listToAttrs (
+        lib.map (type: {
+          name = "${workerName}-${type}";
           value = {
-            max_fails = 0;
+            extraConfig = ''
+              keepalive 32;
+            '';
+            servers = lib.listToAttrs (
+              lib.map (index: {
+                name = "unix:/run/matrix-synapse/${workerName}-${type}-${toString index}.sock";
+                value = {
+                  max_fails = 0;
+                };
+              }) workers
+            );
           };
-        }) workers
-      );
-    };
+        }) ([ ] ++ lib.optional (lib.length workerRoutes.client > 0) "client" ++ lib.optional (lib.length workerRoutes.federation > 0) "federation" ++ lib.optional (lib.length workerRoutes.media > 0) "media")
+      )
+    );
 
     services.nginx = {
       virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs (
         lib.flatten (
-          lib.forEach
-            [
-              "client"
-              "federation"
-              "media"
-            ]
-            (
-              type:
-              lib.map (route: {
-                name = route;
-                value = {
-                  proxyPass = "http://unix:/run/matrix-synapse/${workerName}-${type}.sock";
-                };
-              }) workerRoutes.${type}
-            )
+          lib.forEach ([ ] ++ lib.optional (lib.length workerRoutes.client > 0) "client" ++ lib.optional (lib.length workerRoutes.federation > 0) "federation" ++ lib.optional (lib.length workerRoutes.media > 0) "media") (
+            type:
+            lib.map (route: {
+              name = route;
+              value = {
+                proxyPass = "http://${workerName}-${type}";
+
+              };
+            }) workerRoutes.${type}
+          )
         )
       );
     };