https://github.com/ejunjsh/nginx_module_ratelimiter
🍩 a nignx http module that limits request number
https://github.com/ejunjsh/nginx_module_ratelimiter
Last synced: 3 months ago
JSON representation
🍩 a nignx http module that limits request number
- Host: GitHub
- URL: https://github.com/ejunjsh/nginx_module_ratelimiter
- Owner: ejunjsh
- Created: 2018-12-17T03:05:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-12T00:49:37.000Z (almost 6 years ago)
- Last Synced: 2024-12-29T08:41:56.457Z (4 months ago)
- Language: C
- Homepage:
- Size: 10.7 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nginx_module_ratelimiter
a nignx http module that limits request number
## precondition
download the nginx source code
## configure
# git clone this repo
# go to the nginx source code folder
# specify this repo path of your system
./configure --add-module=/home/sky/code/nginx_module_ratelimiter## build
make && make install
## nginx.conf
# add below ratelimiter option into http section:ratelimiter [expired time(ms)] [slab size(m/k/g)]
http {
....
ratelimiter 500 10m;
....
}
# expired time means all requests have a expired time,when there is a unexpired request,a same request is coming, this new request will be dropped and return 403.
# slab size represets the total memory that store the all unexpired requests,
# if this memory is run out, the nginx will drop the following requests and return 403.
# if the requests in slab memory expire, the memory will be released and treats the new requests again.## test
./nginx
open http://localhost , you will see the `403 Forbidden` in the browser when you refresh the same page many times during 500ms
## reference
[深入理解Nginx(第2版)](https://book.douban.com/subject/26745255/)