撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾
" P% Q+ \; I9 h9 S7 V: Q3 h; g6 S+ ]& x$ Y( r& K! \
憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:
2 ?1 c F! a0 R3 O摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯! @' W. I8 K8 r( M7 U* w- _, i
$ F* C* l' |( O6 ]( x
! L9 c2 I# Z! I3 F+ A+ c亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂
- ]" U% y1 Z( m8 l+ E- location /download/ {
" g" n8 x- A3 |) m. u' h - limit_conn addr 5;
- w- |( V5 ]; ^# ^4 _) S5 s1 m9 s - }
銴鋆賭誨蝣 " |8 S5 V4 {) @& w6 G! d
# S; r: J2 s8 Z6 ?6 t* L
臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺5 B3 n% j' Q* H: f8 h f
- .
' E$ a2 o( c3 v: _; M9 d, W2 C - .
/ M' S" D# T7 C3 f. d- ?' S - .
" Z$ d7 R& q/ e0 V. @6 |: x' p - server {; Z: t$ E- I! Q. G: F
- .5 R9 F0 L! C7 J2 }
- .& |6 X9 \* L5 Y, t3 ?4 w" u8 G
- limit_conn addr 5;: j0 K$ r, I. V5 M" {! |. ]. N
- .3 }3 j, t6 I1 d4 O* P9 T) f
- .
6 p6 O/ j' g b* A( g - }
銴鋆賭誨蝣 ( [4 K5 u0 j4 i/ Z& F+ B
- g. ]! s9 G* E+ h
蝺餌(瘥IP桐蝺)
8 H4 v+ d& g" _* g. J
: ^8 R3 O1 \4 w/ [# ~5 s$ J6 s$ q' t. @
亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂4 a- e! G1 Y* a0 D, c, a2 T1 b/ r
- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣
3 B& P5 K! d0 l2 x4 r支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
- Y7 X! m& Y! J* j1 i
5 E2 Y/ c& Q9 ^- z5 H" m! x% B$ S# X |* ?( F1 \
嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
w* t' W6 M7 [; s& n1 t- location /download/ {6 g/ `8 T y _7 g( F. o
- limit_req zone=one burst=5;
3 i o' c/ d! U - }
銴鋆賭誨蝣 & } L$ ?* D$ B: i) v, \
臬 server 畾菟撠Domain銝撠銝靘桅靘園餌
& Y) C$ k% n4 D3 O7 T" S- .
5 ?. @1 b4 h" {! v - .
n' A! X# W- E8 l/ W y! p2 w - .
- v* [+ C- q. u R; N9 x) s8 [! Y% N - server {
. e0 g! E0 Y& Q0 H4 g - .
/ w" o0 G$ I# j: [$ ^( V - .5 F Z* d5 |* P" v: \
- <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>
) A; q( J2 o# `* k8 A* u+ n. B, { - .+ \# F: B- A$ s. m! ]8 ?
- ." j7 _, j" o5 b# M
- }
銴鋆賭誨蝣 ( _$ {. r2 G2 @4 j, t
1 l; A/ e4 V3 C0 ~+ m3 i& A蝯隢:* t* h" i* g T; U5 r% K/ L, H
! O5 A; h# H! j$ _撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
) l' o5 l/ ]% q, d# G7 V. k. P( k/ G7 t @4 ^( Y, @( ?
嗡隢 :' E0 T( t8 E' B: U v, B! p
https://blog.gtwang.org/linux/ng ... address-tutorial/2/
7 d7 l7 C# l o" ihttp://www.nginx.cn/446.html
- Z! v0 q4 W+ L! t& }8 p& y6 y" k- f
|
|