Rate Limiting

This commit is contained in:
2026-04-25 13:50:16 +03:00
parent a8c3f1b887
commit 798e532dd7
2 changed files with 19 additions and 4 deletions

View File

@@ -181,6 +181,9 @@ wrk-search: ## Нагрузочный тест поиска (wrk2)
-H "Authorization: Bearer $$TOKEN" \ -H "Authorization: Bearer $$TOKEN" \
http://localhost:8080/v1/search?type=event\&q=test http://localhost:8080/v1/search?type=event\&q=test
curl-health:
for i in {1..120}; do curl -k -s -o /dev/null -w "%{http_code}\n" -H "Host: api.eventhub.local" https://localhost/health; done
wrk-health: ## Нагрузочный тест health (wrk2) wrk-health: ## Нагрузочный тест health (wrk2)
wrk -t4 -c100 -d30s -t100 \ wrk -t4 -c100 -d30s -t100 \
-H "Host: api.eventhub.local" \ -H "Host: api.eventhub.local" \

View File

@@ -26,18 +26,30 @@ http:
# - "SecRule REQUEST_URI \"@rx /admin\" \"id:101,phase:1,log,deny,status:403\"" # - "SecRule REQUEST_URI \"@rx /admin\" \"id:101,phase:1,log,deny,status:403\""
- "SecRule ARGS \"@rx (union|select|insert|drop|alter)\" \"id:102,phase:2,log,deny,status:403\"" - "SecRule ARGS \"@rx (union|select|insert|drop|alter)\" \"id:102,phase:2,log,deny,status:403\""
api-ratelimit:
rateLimit:
average: 100
period: 1m
burst: 50
admin-ratelimit:
rateLimit:
average: 20
period: 1m
burst: 5
routers: routers:
# REST API пользователей # REST API пользователей
api: api:
rule: "Host(`api.eventhub.local`)" rule: "Host(`api.eventhub.local`)"
entryPoints: ["web"] entryPoints: ["web"]
middlewares: ["redirect-to-https", "waf"] middlewares: ["redirect-to-https", "api-ratelimit", "waf"]
service: "api" service: "api"
api-secure: api-secure:
rule: "Host(`api.eventhub.local`)" rule: "Host(`api.eventhub.local`)"
entryPoints: ["websecure"] entryPoints: ["websecure"]
tls: true tls: true
middlewares: ["waf"] middlewares: ["api-ratelimit", "waf"]
service: "api" service: "api"
# WebSocket пользователей (без WAF) # WebSocket пользователей (без WAF)
@@ -56,13 +68,13 @@ http:
admin-api: admin-api:
rule: "Host(`admin.eventhub.local`)" rule: "Host(`admin.eventhub.local`)"
entryPoints: ["web"] entryPoints: ["web"]
middlewares: ["redirect-to-https", "waf"] middlewares: ["redirect-to-https", "admin-ratelimit", "waf"]
service: "admin-api" service: "admin-api"
admin-api-secure: admin-api-secure:
rule: "Host(`admin.eventhub.local`)" rule: "Host(`admin.eventhub.local`)"
entryPoints: ["websecure"] entryPoints: ["websecure"]
tls: true tls: true
middlewares: ["waf"] middlewares: ["admin-ratelimit", "waf"]
service: "admin-api" service: "admin-api"
# Админский WebSocket (без WAF) # Админский WebSocket (без WAF)