2020-04-26 15:40:36 +00:00
|
|
|
{ pkgs, config, ... }:
|
2020-06-03 15:58:53 +00:00
|
|
|
let
|
|
|
|
server_name = "maralorn.de";
|
|
|
|
hostName = "matrix.${server_name}";
|
2019-07-31 21:56:52 +00:00
|
|
|
in {
|
2019-08-07 21:40:26 +00:00
|
|
|
services = {
|
|
|
|
nginx = {
|
|
|
|
enable = true;
|
2020-06-03 15:58:53 +00:00
|
|
|
virtualHosts."${server_name}" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations = {
|
|
|
|
"/.well-known/matrix/server".extraConfig = ''
|
|
|
|
default_type application/json;
|
|
|
|
return 200 "{\"m.server\": \"matrix.maralorn.de:443\"}";
|
|
|
|
'';
|
|
|
|
"/.well-known/matrix/client".extraConfig = ''
|
|
|
|
default_type application/json;
|
2020-07-15 18:51:56 +00:00
|
|
|
return 200 "{\"m.homeserver\": { \"base_url\":\"https://matrix.maralorn.de\"} }";
|
2020-06-03 15:58:53 +00:00
|
|
|
'';
|
2020-07-15 18:33:35 +00:00
|
|
|
};
|
2020-07-15 18:27:02 +00:00
|
|
|
extraConfig = "
|
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
|
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
|
|
|
|
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
|
|
|
|
";
|
2020-06-03 15:58:53 +00:00
|
|
|
};
|
2019-08-07 21:40:26 +00:00
|
|
|
virtualHosts."${hostName}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
locations = {
|
|
|
|
"/" = {
|
|
|
|
proxyPass = "http://[::1]:8008";
|
2020-06-03 15:58:53 +00:00
|
|
|
extraConfig = "proxy_set_header X-Forwarded-For $remote_addr;";
|
2019-03-02 15:03:38 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2019-08-07 21:40:26 +00:00
|
|
|
};
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
# Postgres
|
2020-06-03 15:58:53 +00:00
|
|
|
postgresql.enable = true;
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
# Synapse
|
|
|
|
matrix-synapse = {
|
|
|
|
enable = true;
|
2020-04-26 13:29:23 +00:00
|
|
|
package = pkgs.matrix-synapse;
|
2019-08-07 21:40:26 +00:00
|
|
|
enable_metrics = true;
|
2020-06-03 15:58:53 +00:00
|
|
|
inherit server_name;
|
2019-08-07 21:40:26 +00:00
|
|
|
public_baseurl = "https://${hostName}";
|
|
|
|
url_preview_enabled = true;
|
|
|
|
database_type = "psycopg2";
|
|
|
|
max_upload_size = "30M";
|
|
|
|
dynamic_thumbnails = true;
|
2019-08-12 01:04:15 +00:00
|
|
|
registration_shared_secret =
|
|
|
|
config.m-0.private.matrix_registration_secret;
|
2019-08-07 21:40:26 +00:00
|
|
|
macaroon_secret_key = config.m-0.private.macaroon_secret;
|
|
|
|
turn_uris = [ "turn:hera.m-0.eu:3478?transport=udp" ];
|
|
|
|
turn_shared_secret = config.m-0.private.turn_secret;
|
|
|
|
turn_user_lifetime = "5h";
|
|
|
|
allow_guest_access = true;
|
|
|
|
logConfig = ''
|
|
|
|
version: 1
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
formatters:
|
|
|
|
journal_fmt:
|
|
|
|
format: '%(name)s: [%(request)s] %(message)s'
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
filters:
|
|
|
|
context:
|
|
|
|
(): synapse.util.logcontext.LoggingContextFilter
|
|
|
|
request: ""
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
handlers:
|
|
|
|
journal:
|
|
|
|
class: systemd.journal.JournalHandler
|
|
|
|
formatter: journal_fmt
|
|
|
|
filters: [context]
|
|
|
|
SYSLOG_IDENTIFIER: synapse
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
disable_existing_loggers: True
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
loggers:
|
|
|
|
synapse:
|
|
|
|
level: WARN
|
|
|
|
synapse.storage.SQL:
|
|
|
|
level: WARN
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
root:
|
|
|
|
level: WARN
|
|
|
|
handlers: [journal]
|
|
|
|
'';
|
|
|
|
database_args = {
|
|
|
|
user = "matrix-synapse";
|
|
|
|
database = "matrix-synapse";
|
|
|
|
cp_min = 5;
|
|
|
|
cp_max = 10;
|
|
|
|
};
|
|
|
|
report_stats = true;
|
|
|
|
listeners = [
|
2019-08-12 01:04:15 +00:00
|
|
|
{
|
|
|
|
type = "metrics";
|
|
|
|
port = 9148;
|
2020-05-17 12:17:41 +00:00
|
|
|
bind_address = "127.0.0.1";
|
2019-08-12 01:04:15 +00:00
|
|
|
resources = [ ];
|
2020-05-17 12:04:24 +00:00
|
|
|
tls = false;
|
2019-08-12 01:04:15 +00:00
|
|
|
}
|
2019-08-07 21:40:26 +00:00
|
|
|
{
|
|
|
|
port = 8008;
|
|
|
|
bind_address = "::1";
|
|
|
|
resources = [
|
2019-07-31 21:56:52 +00:00
|
|
|
{
|
2019-08-07 21:40:26 +00:00
|
|
|
compress = false;
|
|
|
|
names = [ "client" ];
|
2019-07-31 21:56:52 +00:00
|
|
|
}
|
|
|
|
{
|
2019-08-07 21:40:26 +00:00
|
|
|
compress = false;
|
|
|
|
names = [ "federation" ];
|
2019-07-31 21:56:52 +00:00
|
|
|
}
|
|
|
|
];
|
2019-08-07 21:40:26 +00:00
|
|
|
x_forwarded = true;
|
|
|
|
tls = false;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2019-03-02 15:03:38 +00:00
|
|
|
}
|