Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charts/nginz: Configure rate limits for claiming MLS key packages and getting one2one conversations #3918

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2-features/claim-key-packages-rate-limit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/nginz: Rate limiting claiming MLS key-pacakges by requesting and target user
1 change: 1 addition & 0 deletions changelog.d/2-features/one2one-rate-limit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/nginz: Allow 3000 reqs/min on /conversations/one2one/:user_domain/:user
5 changes: 5 additions & 0 deletions charts/nginz/templates/conf/_nginx.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ http {
0 "";
}

map $rate_limit $rate_limited_by_zuser_path {
1 "$zauth_user$uri";
0 "";
}

map $http_origin $cors_header {
default "";
{{ range $origin := .Values.nginx_conf.allowlisted_origins }}
Expand Down
16 changes: 16 additions & 0 deletions charts/nginz/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ nginx_conf:
user_rate_limit_request_zones:
- limit_req_zone $rate_limited_by_addr zone=reqs_per_addr_sso:12m rate=50r/s;
- limit_req_zone $rate_limited_by_zuser zone=reqs_per_user_signatures:12m rate=10r/m;
- limit_req_zone $rate_limited_by_zuser_path zone=key_package_claims:12m rate=100r/m;
- limit_req_zone $rate_limited_by_zuser zone=one2one_conv:12m rate=3000r/m;

# The origins from which we allow CORS requests. These are combined with
# 'external_env_domain' and 'additional_external_env_domains' to form a full
Expand Down Expand Up @@ -209,6 +211,11 @@ nginx_conf:
- path: /clients
envs:
- all
- path: /mls/key-packages/claim
envs:
- all
specific_user_rate_limit: key_package_claims
specific_user_rate_limit_burst: 100
- path: /mls/key-packages
smatting marked this conversation as resolved.
Show resolved Hide resolved
envs:
- all
Expand Down Expand Up @@ -440,6 +447,15 @@ nginx_conf:
- all
max_body_size: 40m
body_buffer_size: 256k
- path: /conversations/one2one/
envs:
- all
# During MLS migration, this endpoint gets called _a lot_.
specific_user_rate_limit: one2one_conv
specific_user_rate_limit_burst: 1000
# The name is a little misleading, this just disables default rate
# limiting in favour of the specific one defined above.
unlimited_requests_endpoint: true
- path: /conversations/([^/]*)/([^/]*)/protocol
envs:
- all
Expand Down
Loading