nginx 限流配置
上配置
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
limit_conn_zone $binary_remote_addr zone=addr:5m;
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
limit_conn perip 10;
limit_conn perserver 1000;
#root html;
root /usr/local/liliyunweb;
index index.html index.htm;
}
先在http里配置limit_conn_zone, location 再配置limit_conn, 蓝色和绿色背景的配置是一一对应的。