Score:1

Why is my nginx rate limiting not working?

br flag

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
   }
}
Score:1
jp flag

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

Nstevens avatar
br flag
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.
CalfCrusher avatar
in flag
i have the exact same problem, after hours and hours i'm unable to solve, my code is like yours i can't understand.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.