撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾
4 a4 V" N7 h) k/ n( n% Q& e' n1 d+ N$ Y3 k
憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:& U L8 U- ~9 Y& h
摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯
- Y- D/ a- b+ D7 D) ^/ o5 C
+ E: V F4 v9 I. c; D5 R* x5 a: E( e2 z$ s4 L3 l
亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂: O' j. r6 o# A& v- b
- location /download/ {, U$ ?; [* B+ P0 b
- limit_conn addr 5;6 ]+ w+ c9 i8 M/ m8 [8 @% |* ^
- }
銴鋆賭誨蝣 " j8 u+ ?' a1 Z& A9 n8 b+ E! `
, U3 F8 z/ | h& u臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺9 g( V3 ^- c3 m& X! {
- .
2 K8 v: ] f0 i% T - .
/ n. O# E0 A+ u& j0 L% m* { - .
: s! g7 |3 u3 p: L# R. X% R3 ^ - server {
. U( u- g: x+ }0 s - .
" R2 h5 a6 e' D; ` - .8 M- o8 Q" N+ D3 e1 J6 `1 L1 Q
- limit_conn addr 5;+ l Q9 j3 H" }+ {: B
- .
0 I% S* X' I; c. |2 O - .8 c# U# v) R$ J- v; h+ m) P3 n1 s
- }
銴鋆賭誨蝣 % V3 k8 X1 v; Z- D
# d9 B% Q+ O2 s7 `
蝺餌(瘥IP桐蝺)( H0 l" W% j8 q) C
$ p8 [! y8 `* u% C- @8 k+ j8 t3 U8 n" I. d" c# ~ p; r
亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂& Q! a" G7 k; h9 G8 f2 H
- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣
" a U# a6 }. f/ U3 H7 F: C+ ]支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
0 r4 b! ?& d5 g1 P* E
5 R" E T7 e( u0 B0 e7 I
9 N6 ~' A' ?) j, G" f0 `" u6 z嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
, D0 m/ ~% P" @ o7 G" ?, Z9 Z( P- location /download/ {
( v( p- g8 l! p - limit_req zone=one burst=5;5 f4 S- u1 i" G
- }
銴鋆賭誨蝣
0 @( i$ ]' \6 b; J# Y6 h臬 server 畾菟撠Domain銝撠銝靘桅靘園餌
* L! N" J/ V7 b% g0 l; U8 C% a- .7 Y, Y- Y8 j) z
- .
9 X4 O/ {( L2 c7 |6 }8 \ - .# n, B' |; U' |
- server {
: C) V4 y; U" L - .# z: Z0 v% h9 k# n0 u
- .6 ^8 h3 K1 e( \* o0 f6 ~& E
- <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>
4 f, Y4 e1 ?# R - ./ t# ^% Y6 r' z
- .
: K8 s; k3 U/ o - }
銴鋆賭誨蝣
5 F* c) }2 s O( Z3 A/ A! k
4 X; n8 p. Y2 l7 u! _蝯隢:9 D4 u7 C V- |& Q) f. ~
b3 H4 [1 i n$ ~
撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝) w5 p1 G. q4 l- s, G4 z
+ U0 r$ y/ R; C2 L嗡隢 :9 h, z' p4 f% H) F8 f! o
https://blog.gtwang.org/linux/ng ... address-tutorial/2/3 X3 G5 A3 E. G6 c: f
http://www.nginx.cn/446.html& F- K. a% @, V8 \9 E3 ~1 F4 p
* I L$ l+ `% r1 K6 K
|
|