ngx_http_limit_req_module 模块用于限制每个ip访问每个key的请求速率
直接看配置:
worker_processes 1;
worker_rlimit_nofile 65535;
error_log /home/inca/logs/error.log;
user inca inca;
pid /home/inca/logs/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
limit_conn_zone $binary_remote_addr zone=addr:10m;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
server {
listen 8990;
server_name www.ofo.com;
root /home/inca/www;
location / {
index index.html index.php index.htm;
limit_conn addr 1;
limit_req zone=one burst=5;
每秒超过五次了进行返回503错误