diff options
author | Rory& <root@rory.gay> | 2024-08-17 10:47:57 +0200 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-08-17 10:47:57 +0200 |
commit | e6e5f18aa1329325cfcd615b1adc8ae4feb6013a (patch) | |
tree | 2b90564bcd310c2f27b8cca940cf5af5c3f6f8b2 /host/Rory-nginx/services/matrix/synapse/workers/auth.nix | |
parent | event -> events (diff) | |
download | Rory-Open-Architecture-e6e5f18aa1329325cfcd615b1adc8ae4feb6013a.tar.xz |
Fix synapse paths?
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/auth.nix')
-rw-r--r-- | host/Rory-nginx/services/matrix/synapse/workers/auth.nix | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/auth.nix b/host/Rory-nginx/services/matrix/synapse/workers/auth.nix index 37cdc85..50d52c6 100644 --- a/host/Rory-nginx/services/matrix/synapse/workers/auth.nix +++ b/host/Rory-nginx/services/matrix/synapse/workers/auth.nix @@ -22,6 +22,9 @@ let media = [ ]; }; in +let + enabledResources = lib.optionals (lib.length workerRoutes.client > 0) [ "client" ] ++ lib.optionals (lib.length workerRoutes.federation > 0) [ "federation" ] ++ lib.optionals (lib.length workerRoutes.media > 0) [ "media" ]; +in { config = lib.mkIf (cfg.authWorkers > 0) { services.matrix-synapse = { @@ -41,29 +44,30 @@ in name = "${workerName}-${toString index}"; value = { worker_app = "synapse.app.generic_worker"; - worker_listeners = [ - { - type = "http"; - path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; - resources = [ - { - names = [ "replication" ]; - compress = false; - } - ]; - } - { + worker_listeners = + [ + { + type = "http"; + path = "/run/matrix-synapse/${workerName}-${toString index}.sock"; + resources = [ + { + names = [ "replication" ]; + compress = false; + } + ]; + } + ] + ++ lib.map (type: { type = "http"; - path = "/run/matrix-synapse/${workerName}-client-${toString index}.sock"; + path = "/run/matrix-synapse/${workerName}-${type}-${toString index}.sock"; mode = "666"; resources = [ { - names = [ "client" ]; + names = [ type ]; compress = false; } ]; - } - ]; + }) enabledResources; database = ( import ../db.nix { inherit dbGroup; @@ -75,13 +79,14 @@ in ); }; - services.nginx.upstreams = ( - lib.listToAttrs ( + services.nginx = { + upstreams = lib.listToAttrs ( lib.map (type: { name = "${workerName}-${type}"; value = { extraConfig = '' keepalive 32; + least_conn; ''; servers = lib.listToAttrs ( lib.map (index: { @@ -92,20 +97,21 @@ in }) 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") - ) - ); + }) enabledResources + ); - services.nginx = { virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( lib.flatten ( - 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") ( + lib.forEach enabledResources ( type: lib.map (route: { name = route; value = { proxyPass = "http://${workerName}-${type}"; - + extraConfig = '' + proxy_http_version 1.1; + proxy_set_header Connection ""; + ''; }; }) workerRoutes.${type} ) |