Rate Limiting does not happen for particular IP address
See original GitHub issueLimits = 40/day Once 40 requests are served irrespective of the IP Addresses, It redirects to the 429 view. So even the visitor whose visiting the site for the first time, is redirected to 429. Can we have rate limiting for every IP address?
var RateLimiter = require('limiter').RateLimiter;
var limiter = new RateLimiter(40, 'day', true); // fire CB immediately
app.use(function (req, res, next) {
if ((req.headers["user-agent"].indexOf("Googlebot") != -1) || req.url == "/429")
next();
else
limiter.removeTokens(1, function(err, remainingRequests) {
if (remainingRequests < 0) {
res.redirect('/429');
} else {
next();
}
});
});
Issue Analytics
- State:
- Created 10 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
What is rate limiting? | Rate limiting and bots - Cloudflare
Typically, rate limiting is based on tracking the IP addresses that requests are coming from, and tracking how much time elapses between each...
Read more >Rate Limiting - Pode
You can either rate limit a specific IP address, a subnet mask, or every address using all . You can also supply an...
Read more >Rate-limit a large number of IP addresses - Cisco Community
I am trying to put rate limiting on the UPLink interface for each individual IP address. So, every single IP address would have...
Read more >Understanding and Bypassing Rate Limiting's
If repeated requests, from either a tool or a user, are being sent to a particular endpoint, “rate limiting” is a way that...
Read more >NGINX Rate Limiting
IP addresses on the allowlist do not match the first rate limit (req_zone) but do match the second (req_zone_wl) and so are limited...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I followed your advice and combined your limiter with the node-cache:
Now specific requests can be limited on a per-IP basis from the express-app like this:
Just if anyone would come across this issue in the future! 😃
Hi guys thanks for the answers, my calls are actually API calls so my while cycle is calling API calls, I thought that should work. I will try it with the tryRemoveTokens, but my gratest issue was that if I set a rate of 10 calls per hour everything worked after the 10th it stopped but if I set 10 calls per second than are the issues presenting and it will let me call all the 30 API calls that I have in the while.