summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/auth.nix
diff options
context:
space:
mode:
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}
+          )
         )
       );
     };