1

I have Nginx in front of apache to terminate SSL and filter things. I'm trying to get rate limiting working using these docs.

When I test a loop of 10 requests with curl, all the requests for /mytest/ are still being forwarded back to Apache - 8 of them show the same timestamp down to the second. I'm expecting only one request/second should reach Apache. What have I overlooked?

My curl command:

for i in $(seq 1 10); do curl --verbose  --request "GET /mytest" https://myhost.com; done

nginx.conf:

http {
   ...
   include /etc/nginx/conf.d/*.conf;
   ...
}

/etc/nginx/conf.d/rate-limit.conf:

limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

server {
   location /mytest/ {
      limit_req zone=one;    #:: removed burst=5 for testing - made no diff
   }
}

1 Answer 1

1

Your location with rate limit is /mytest/ but you are requesting /mytest (without a trailing slash). These requests won't match that location.

2
  • Thanks for the info. I'm not sure what I did, but it is working now. Strangely enough, it seems to be working with or without the trailing slash so not sure why that is.
    – Nstevens
    Commented Jan 18, 2022 at 14:54
  • i have the exact same problem, after hours and hours i'm unable to solve, my code is like yours i can't understand. Commented Jun 19, 2023 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .