fix:#7 added limit to POST in nginx config

This commit is contained in:
Elmar Kresse
2024-06-10 21:29:56 +02:00
parent 5e8365f3c5
commit 085ffe1baf
3 changed files with 29 additions and 5 deletions

View File

@ -107,6 +107,12 @@ http {
1 $binary_remote_addr;
}
# Different rate limits for different request methods
map $request_method $limit_zone {
POST createFeed; # Create feed is limited to 1 request per minute
default feed; # All other requests are limited to 20 requests per minute
}
# Limit the number of requests per IP
limit_req_zone $limit_key zone=feed:20m rate=20r/m;
limit_req_zone $limit_key zone=createFeed:10m rate=1r/m;
@ -125,7 +131,8 @@ http {
proxy_read_timeout 600s;
proxy_send_timeout 600s;
send_timeout 600s;
limit_req zone=feed burst=10 nodelay;
limit_req zone=$limit_zone burst=10 nodelay;
limit_req_status 429;
}
location / {
@ -146,7 +153,8 @@ http {
proxy_read_timeout 600s;
proxy_send_timeout 600s;
send_timeout 600s;
limit_req zone=feed burst=10 nodelay;
limit_req zone=$limit_zone burst=10 nodelay;
limit_req_status 429;
}
location / {
@ -181,7 +189,8 @@ http {
proxy_read_timeout 600s;
proxy_send_timeout 600s;
send_timeout 600s;
limit_req zone=feed burst=10 nodelay;
limit_req zone=$limit_zone burst=10 nodelay;
limit_req_status 429;
}
location /api {