weserv / rate-limit-nginx-module Goto Github PK
View Code? Open in Web Editor NEWA Redis backed rate limit module for Nginx web servers.
License: BSD 3-Clause "New" or "Revised" License
A Redis backed rate limit module for Nginx web servers.
License: BSD 3-Clause "New" or "Revised" License
The connections with redis will remain in TIME_WAIT state for a period of time (I think 1 - 4 minute). If you log 10.000 / minute you will have aprox 10.000 connection in time_wait state.
Can you confirm does this module supports proxy pass?
Since it is production-ready, can you please tag a release version here, e.g. 1.0.0?
Hi, I am trying this module to work with API key based rate limiting. We want to implement rate limit on API key based on tier. Some API key required to have 50 RPS and Some required to have 100 RPS. Our implementation of rate limiting is below.
map $ms_apikey $ratelimit_tier10000 {
include /etc/nginx/ratelimit_tier10000.map;
default '';
}
map $ms_apikey $ratelimit_tier1000 {
include /etc/nginx/ratelimit_tier1000.map;
default '';
}
map $ms_apikey $ratelimit_tier500 {
include /etc/nginx/ratelimit_tier500.map;
default '';
}
map $ms_apikey $ratelimit_tier200 {
include /etc/nginx/ratelimit_tier200.map;
default '';
}
map $ms_apikey $ratelimit_tier100 {
include /etc/nginx/ratelimit_tier100.map;
default '';
}
map $ms_apikey $ratelimit_tier50 {
include /etc/nginx/ratelimit_tier50.map;
default '';
}
map $ratelimit_tier10000$ratelimit_tier1000$ratelimit_tier500$ratelimit_tier50$ratelimit_tier200$ratelimit_tier100 $ratelimit_default {
'' $ms_apikey;
default '';
}
Here we store API keys on file based on their tiers and map it in nginx.conf file. This mapping works well with default rate limiting module. Implementation on location block like below.
location /somepath {
rate_limit $ratelimit_default requests=5 period=1s burst=5;
rate_limit $ratelimit_tier50 requests=50 period=1s burst=50;
rate_limit $ratelimit_tier100 requests=100 period=1s burst=110;
rate_limit_pass redis;
proxy_pass http://www.example.com;
}
I have stored API key in /etc/nginx/ratelimit_tier50.map file so API key should have 50 RPS rate limit. While running load test with 150 RPS it isn't blocking nor i see any movement on redis. Please guide if i am doing something wrong in implementation.
Is there a way to use this to sync rate limits on multiple load balancer servers in cluster?
I am trying to install this module in existing nginx. Followed the steps and tried configuring using below command.
./configure --with-compat --add-dynamic-module=rate-limit-nginx-module --prefix=/etc/nginx
Module ngx_http_rate_limit_module.so is getting installed in /etc/nginx/modules but when i add directive rate_limit_pass redis;
it is giving below error.
nginx: [emerg] unknown directive "rate_limit_pass" in /etc/nginx/conf.d/file.conf:28
Tried loading module in nginx.conf load_module modules/ngx_http_rate_limit_module.so;
nginx: [emerg] module "/etc/nginx/modules/ngx_http_rate_limit_module.so" is not binary compatible in /etc/nginx/nginx.conf:3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.