撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾& X( E9 ~5 [) P7 ^( w. s1 i
0 }) W: J9 @2 e& h7 w2 v9 @ J
憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:( M7 U1 X, A, j3 s' J8 H: Y
摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯
9 l& j5 [. p, Y" y: H* h9 \! r9 C3 d: P
j5 B/ B( K& a7 r3 T* D/ u+ X5 g; p
亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂, w0 ]4 O8 k4 D3 n7 Z( x
- location /download/ {
- {3 [3 v a& N - limit_conn addr 5;' V) V; S q# d% _" B) ^" x
- }
銴鋆賭誨蝣 $ N6 [2 K! N% ]5 V4 `
8 {" z" m' s7 e+ L8 \3 k
臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺
2 M0 c2 N. k; s( p. E1 g- .$ V6 m7 `& s, D) C; L2 g/ m. \
- ., k' u( n2 p) M) y; h& }! K
- .: a; H$ K2 B5 n; ?
- server {; Y* Q7 d& r+ e, K
- .
4 I) U" x9 G0 p* F6 x3 q; j* h7 |9 g - .
* `# k; `2 y+ O3 F0 p m: U - limit_conn addr 5;
, y6 y/ i4 i4 Q! U0 x: z* z6 J - ./ n2 [2 o; T( C$ F: d# M
- .
3 j' i* w, g+ n: `5 ? _/ u - }
銴鋆賭誨蝣
R' }5 E1 h% |+ F1 y, ~: {( M7 Y6 c ]2 b h
蝺餌(瘥IP桐蝺)1 i8 x9 w- i, g& K9 M# j: C/ @
) f, u: @$ K3 f) ?, K/ o; r
7 ^3 w% V* l4 R7 y7 D, H; |亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂% Q, D) `# g1 _3 a S
- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣 & Y. D5 e# Z3 M! M7 L0 \: s
支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
2 P4 V5 l, H! K1 e6 \0 U
7 b1 k, }. J. g/ F' U0 d" E! r" v7 I1 A
嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗4 @& V9 X/ I6 t7 v+ ^" f
- location /download/ {8 K+ }, [1 o0 K% f
- limit_req zone=one burst=5;
; }8 Q3 g6 q+ \( o - }
銴鋆賭誨蝣
) L, u0 {6 Q# M臬 server 畾菟撠Domain銝撠銝靘桅靘園餌 k2 @" n* Q& B5 p
- .0 z f; ?! u4 U
- .: ^8 m! l( t, u+ W
- .
9 h0 S$ }# B4 J w0 G* i" k/ A: y - server {! F' y3 w2 R1 e0 c9 K6 ?
- .
& J( O3 h4 K- T+ { - .
& m$ I: `9 G1 \$ ]2 x8 I. }, m) g2 x - <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>
- b6 |8 J, r4 t! o! x/ t - .
D0 e6 r" l; C0 _7 I) ?' W - .: n. t/ T" o4 D+ z3 T" s
- }
銴鋆賭誨蝣 / o+ X' B% V, C; q& k$ L4 K
( S# R* a1 z) M/ ~+ S; m2 V0 N8 \
蝯隢:
5 v6 I5 v& f5 D" C. o, n2 a0 g/ p8 d
撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
5 y* k1 A; c0 J3 B0 A' N4 e: t4 j. E; y
1 C) ]' m3 {3 w( }& G$ y e嗡隢 :8 p% V9 ?. o, l( P6 ?
https://blog.gtwang.org/linux/ng ... address-tutorial/2// W4 z9 l. Q; D7 P& H) N4 ~
http://www.nginx.cn/446.html
+ r; i, [; f; `, [
& m/ ~* s7 [! B; _; N, w, X |
|