## 用户的 IP 地址 $binary_remote_addr 作为 Key,每个 IP 地址最多有 50 个并发连接
## 你想开 几千个连接 刷死我? 超过 50 个连接,直接返回 503 错误给你,根本不处理你的请求了
limit_conn
_zone
$binary_remote_addr
zone
=
TotalConnLimitZone
:
10m
;
limit_conn
TotalConnLimitZone
50
;
limit_conn_log_level
notice
;
## 用户的 IP 地址 $binary_remote_addr 作为 Key,每个 IP 地址每秒处理 10 个请求
## 你想用程序每秒几百次的刷我,没戏,再快了就不处理了,直接返回 503 错误给你
limit_req
_zone
$binary_remote_addr
zone
=
ConnLimitZone
:
10m
rate
=
10r
/
s
;
limit_req_log_level
notice
;
## 具体服务器配置
server
{
listen
80
;
location
~
\
.php
$
{
## 最多 5 个排队, 由于每秒处理 10 个请求 + 5个排队,你一秒最多发送 15 个请求过来,再多就直接返回 503 错误给你了
limit_req
zone
=
ConnLimitZone
burst
=
5
nodelay
;
fastcgi
_pass
127.0.0.1
:
9000
;
fastcgi_index
index
.php
;
include
fastcgi_params
;
}
}