diff --git a/docker/nginx.conf b/docker/nginx.conf index ef37b03..946f737 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -17,12 +17,21 @@ http { default $http_x_forwarded_proto; '' $scheme; } + # One shared budget: the external proxy's client-IP forwarding is not verified. + map "$request_method:$uri" $auth_admission_key { + default ""; + POST:/api/v1/auth/login auth; + POST:/api/v1/auth/register auth; + } + limit_req_zone $auth_admission_key zone=auth_admission:1m rate=2r/s; + limit_req_status 429; server { listen 8080; server_name _; root /usr/share/nginx/html; resolver 127.0.0.11 valid=5s ipv6=off; location /api/ { + limit_req zone=auth_admission burst=5 nodelay; set $backend http://backend:3000; proxy_pass $backend$request_uri; proxy_set_header Host $http_host;