Compare commits
2 commits
7df9d7ef4f
...
e77bc1e641
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e77bc1e641 | ||
|
|
d2949df2fb |
1 changed files with 14 additions and 9 deletions
|
|
@ -1,7 +1,14 @@
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.machine.synapse) domain port;
|
cfg = config.machine.synapse;
|
||||||
maxUploadSize = config.services.matrix-synapse.settings.max_upload_size;
|
|
||||||
|
clientConfig."m.homeserver".base_url = baseUrl;
|
||||||
|
serverConfig."m.server" = "${cfg.domain}:443";
|
||||||
|
mkWellKnown = data: ''
|
||||||
|
default_type application/json;
|
||||||
|
add_header Access-Control-Allow-Origin *;
|
||||||
|
return 200 '${builtins.toJSON data}';
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
systemd.services.nginx.serviceConfig.SupplementaryGroups = [ "matrix-synapse" ];
|
systemd.services.nginx.serviceConfig.SupplementaryGroups = [ "matrix-synapse" ];
|
||||||
|
|
@ -9,18 +16,16 @@ in
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
appendHttpConfig = ''
|
appendHttpConfig = ''
|
||||||
limit_req_zone $binary_remote_addr zone=matrix:10m rate=50r/s;
|
limit_req_zone $binary_remote_addr zone=matrix:10m rate=50r/s;
|
||||||
limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
|
|
||||||
'';
|
'';
|
||||||
upstreams."matrix-synapse".servers = {
|
virtualHosts.${cfg.domain} = {
|
||||||
"unix:/run/matrix-synapse/matrix-synapse.sock" = { };
|
|
||||||
};
|
|
||||||
virtualHosts.${domain} = {
|
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
|
|
||||||
locations = {
|
locations = {
|
||||||
|
"= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
|
||||||
|
"= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
|
||||||
"^~ /_matrix" = {
|
"^~ /_matrix" = {
|
||||||
proxyPass = "http://127.0.0.1:${toString port}";
|
proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
limit_req zone=matrix burst=100 nodelay;
|
limit_req zone=matrix burst=100 nodelay;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
|
@ -36,7 +41,7 @@ in
|
||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
"= /health" = {
|
"= /health" = {
|
||||||
proxyPass = "http://127.0.0.1:${toString port}";
|
proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
access_log off;
|
access_log off;
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue