From 9410056dfb9abfe611353531028e8f45ca01e194 Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Sat, 22 Feb 2025 19:36:17 +1100 Subject: [PATCH] Updated caddyfile to use rate limiting and connection limits --- deploy/caddy/Caddyfile | 62 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/deploy/caddy/Caddyfile b/deploy/caddy/Caddyfile index 7f29089..b0f4573 100644 --- a/deploy/caddy/Caddyfile +++ b/deploy/caddy/Caddyfile @@ -1,12 +1,58 @@ projectreshoot.com { - reverse_proxy localhost:3000 localhost:3001 localhost:3002 { - health_uri /healthz - fail_duration 30s - } + rate_limit { + zone auth { + match { + method POST + path /login /register + } + key {remote_host} + events 4 + window 1m + } + zone client { + key {remote_host} + events 100 + window 1m + } + } + reverse_proxy localhost:3000 localhost:3001 localhost:3002 { + transport http { + max_conns_per_host 10 + } + health_uri /healthz + fail_duration 30s + } + log { + output file /var/log/caddy/access.log + } } + staging.projectreshoot.com { - reverse_proxy localhost:3005 localhost:3006 localhost:3007 { - health_uri /healthz - fail_duration 30s - } + rate_limit { + zone auth { + match { + method POST + path /login /register + } + key {remote_host} + events 4 + window 1m + } + zone client { + key {remote_host} + events 100 + window 1m + } + } + reverse_proxy localhost:3005 localhost:3006 localhost:3007 { + transport http { + max_conns_per_host 10 + } + health_uri /healthz + fail_duration 30s + } + log { + output file /var/log/caddy/access-staging.log + } } +