feat(services/synapse): simplify reverse proxy
Some checks failed
Nix CI / build (push) Failing after 5m55s
Some checks failed
Nix CI / build (push) Failing after 5m55s
This commit is contained in:
parent
9ff92a89e3
commit
7df9d7ef4f
1 changed files with 9 additions and 57 deletions
|
|
@ -8,11 +8,7 @@ in
|
|||
|
||||
services.nginx = {
|
||||
appendHttpConfig = ''
|
||||
limit_req_zone $binary_remote_addr zone=matrix_login:10m rate=1r/s;
|
||||
limit_req_zone $binary_remote_addr zone=matrix_register:10m rate=1r/m;
|
||||
limit_req_zone $binary_remote_addr zone=matrix_api:10m rate=20r/s;
|
||||
limit_req_zone $binary_remote_addr zone=matrix_media:10m rate=10r/s;
|
||||
limit_req_zone $binary_remote_addr zone=matrix_federation: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 = {
|
||||
|
|
@ -23,65 +19,21 @@ in
|
|||
enableACME = true;
|
||||
|
||||
locations = {
|
||||
# Synapse client API
|
||||
"/_matrix/client" = {
|
||||
"^~ /_matrix" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
extraConfig = ''
|
||||
limit_req zone=matrix_api burst=50 nodelay;
|
||||
client_max_body_size ${maxUploadSize};
|
||||
'';
|
||||
};
|
||||
|
||||
# Login endpoint with stricter rate limiting
|
||||
"~ ^/_matrix/client/(r0|v3)/login$" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
extraConfig = ''
|
||||
limit_req zone=matrix_login burst=3 nodelay;
|
||||
'';
|
||||
};
|
||||
|
||||
# Registration with very strict rate limiting
|
||||
"~ ^/_matrix/client/(r0|v3)/register" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
extraConfig = ''
|
||||
limit_req zone=matrix_register burst=2 nodelay;
|
||||
'';
|
||||
};
|
||||
|
||||
# Sync endpoint with longer timeout
|
||||
"~ ^/_matrix/client/(r0|v3|unstable)/sync" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
extraConfig = ''
|
||||
limit_req zone=matrix_api burst=50 nodelay;
|
||||
limit_req zone=matrix burst=100 nodelay;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_read_timeout 600s;
|
||||
'';
|
||||
};
|
||||
|
||||
# Media
|
||||
"/_matrix/media" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
extraConfig = ''
|
||||
limit_req zone=matrix_media burst=100 nodelay;
|
||||
client_max_body_size ${maxUploadSize};
|
||||
'';
|
||||
};
|
||||
|
||||
# Federation
|
||||
"/_matrix/federation" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
extraConfig = ''
|
||||
limit_req zone=matrix_federation burst=100 nodelay;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 600s;
|
||||
client_max_body_size 50M;
|
||||
'';
|
||||
};
|
||||
|
||||
"/_matrix/key" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
extraConfig = ''
|
||||
limit_req zone=matrix_federation burst=50 nodelay;
|
||||
'';
|
||||
};
|
||||
|
||||
# Health check
|
||||
"= /health" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue