diff --git a/modules/system/services/server/nginx/virtualhosts/default.nix b/modules/system/services/server/nginx/virtualhosts/default.nix index d3d9510..149652b 100644 --- a/modules/system/services/server/nginx/virtualhosts/default.nix +++ b/modules/system/services/server/nginx/virtualhosts/default.nix @@ -1,6 +1,7 @@ { ... }: { imports = [ + ./p1 ./p2 ]; } diff --git a/modules/system/services/server/nginx/virtualhosts/p1/default.nix b/modules/system/services/server/nginx/virtualhosts/p1/default.nix new file mode 100644 index 0000000..364ee40 --- /dev/null +++ b/modules/system/services/server/nginx/virtualhosts/p1/default.nix @@ -0,0 +1,26 @@ +{ config, lib, ... }: +{ + services.nginx.virtualHosts."${config.domains.p1}" = lib.mkIf config.system.server.enable { + enableACME = true; + addSSL = true; + locations = { + "/.well-known/matrix/client".extraConfig = '' + default_type application/json; + return 200 ' + { + "m.homeserver": { + "base_url": "https://matrix.${config.domains.p1}" + }, + "m.identity_server": { + "base_url": "https://matrix.org" + } + } + '; + ''; + "/.well-known/matrix/server".extraConfig = '' + default_type application/json; + return 200 '{ "m.server": "matrix.${config.domains.p1}:443" }'; + ''; + }; + }; +} diff --git a/modules/system/services/server/nginx/virtualhosts/p2/default.nix b/modules/system/services/server/nginx/virtualhosts/p2/default.nix index 7ed8f09..2b910cc 100644 --- a/modules/system/services/server/nginx/virtualhosts/p2/default.nix +++ b/modules/system/services/server/nginx/virtualhosts/p2/default.nix @@ -4,28 +4,5 @@ enableACME = true; addSSL = true; root = "/var/www/landing-page"; - locations = { - "/.well-known/matrix/client".extraConfig = '' - default_type application/json; - return 200 ' - { - "m.homeserver": { - "base_url": "https://matrix.${config.domains.p2}" - }, - "m.identity_server": { - "base_url": "https://matrix.org" - }, - "org.matrix.msc3575.proxy": { - "url": "https://matrix.${config.domains.p2}" - } - } - '; - ''; - - "/.well-known/matrix/server".extraConfig = '' - default_type application/json; - return 200 '{ "m.server": "matrix.${config.domains.p2}:443" }'; - ''; - }; }; } diff --git a/modules/system/services/server/social/matrix/element/nginx/default.nix b/modules/system/services/server/social/matrix/element/nginx/default.nix index d56c538..82488c2 100644 --- a/modules/system/services/server/social/matrix/element/nginx/default.nix +++ b/modules/system/services/server/social/matrix/element/nginx/default.nix @@ -1,6 +1,6 @@ { pkgs, config, lib, ... }: { - services.nginx.virtualHosts."chat.${config.domains.p1}" = lib.mkIf config.services.matrix-synapse.enable { + services.nginx.virtualHosts."chat.${config.domains.p2}" = lib.mkIf config.services.matrix-synapse.enable { enableACME = true; addSSL = true; root = "${pkgs.element-web}"; diff --git a/modules/system/services/server/social/matrix/synapse/default.nix b/modules/system/services/server/social/matrix/synapse/default.nix index e3e40bc..88c61f6 100644 --- a/modules/system/services/server/social/matrix/synapse/default.nix +++ b/modules/system/services/server/social/matrix/synapse/default.nix @@ -1,5 +1,9 @@ { pkgs, config, ... }: { + imports = [ + ./nginx + ]; + services.matrix-synapse = { enable = config.system.server.enable; settings = { @@ -11,7 +15,13 @@ { port = 8008; bind_addresses = [ "::" "0.0.0.0" ]; - resources = [ { compress = true; names = [ "client" "federation" ]; } ]; + resources = [{ + compress = true; + names = [ + "client" + "federation" + ]; + }]; type = "http"; tls = false; x_forwarded = true; @@ -19,7 +29,7 @@ ]; email = { - notif_from = "Jimbo's Matrix "; + notif_from = "NixFox Matrix "; smtp_host = "mx.${config.domains.p1}"; smtp_user = "noreply@${config.domains.p1}"; smtp_pass = config.secrets.noreplyPassword; @@ -33,10 +43,6 @@ # Allow only this range of emails allowed_local_3pids = [ - { - medium = "email"; - pattern = ''^[^@]+@jimbosfiles\.com$''; - } { medium = "email"; pattern = ''^[^@]+@nixfox\.ca$''; diff --git a/modules/system/services/server/social/matrix/synapse/nginx/default.nix b/modules/system/services/server/social/matrix/synapse/nginx/default.nix index ec4bcad..60dc12d 100644 --- a/modules/system/services/server/social/matrix/synapse/nginx/default.nix +++ b/modules/system/services/server/social/matrix/synapse/nginx/default.nix @@ -1,13 +1,12 @@ -{ config, ... }: +{ config, lib, ... }: { - services.nginx.virtualHosts."matrix.${config.domains.p1}" = { + services.nginx.virtualHosts."matrix.${config.domains.p1}" = lib.mkIf config.services.matrix-synapse.enable { enableACME = true; forceSSL = true; locations = { "/".extraConfig = ''return 403;''; - "/client".proxyPass = "http://127.0.0.1:8009"; + "/client".proxyPass = "http://127.0.0.1:8008"; "/_matrix".proxyPass = "http://127.0.0.1:8008"; - "/_matrix/client/unstable/org.matrix.msc3575/sync".proxyPass = "http://127.0.0.1:8009"; "/_synapse/client".proxyPass = "http://127.0.0.1:8008"; }; };