I'm using Plesk 18 with NGINX as a proxy in front of Apache2 for a CakePHP application. I have set up rate limiting in my NGINX configuration (/etc/nginx/nginx.conf) with limit_req_zone $binary_remote_addr zone=mylimit:10m rate=5r/s;. I want to apply this rate limit specifically to a route /my/path, which is defined in CakePHP as follows: $routes->connect('/my/path', ['controller' => 'My', 'action' => 'path']);.
However, when I add the following additional NGINX directive in Plesk:
location /my/path { limit_req zone=mylimit burst=10 nodelay; proxy_pass https://PUBLIC-SERVER-IP:PORT; } I receive a 404 error for that route, which otherwise works fine without this NGINX configuration. My goal is to also eventually block IPs that exceed the rate limit for a specified duration. How can I correctly configure NGINX to apply rate limiting to this route without causing a 404 error, ensuring requests are properly forwarded to Apache?