撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾) J2 i* n" P" e
4 N5 Z6 f* A3 ~. @3 X4 F3 `! _! }憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:
1 T2 F3 z2 y: h! E: |* U1 r a4 e* Q, t摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯+ M. H* o( k% M: _! m( R8 ~
- Y$ l- i/ J/ [5 b6 }- g7 ?
/ F3 b* R2 [( g* M; G9 E2 D亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂, Y8 @/ ?6 H* A) V6 O0 `
- location /download/ {
7 C* g: }7 o# t, ] - limit_conn addr 5;4 b+ {+ G, v# E* M. D( H
- }
銴鋆賭誨蝣 ! ]! j, e7 Y$ L9 b4 {0 Q
5 ?) @+ x7 Q: c7 J& Q) o) H
臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺/ A) ^3 P: E2 h# I' S8 j3 g% m
- .
& ^$ P S+ e6 h! L7 x! `5 t - .
5 h" [8 f' }5 p - .7 j$ s5 B/ e. X$ j2 c* [# g
- server {* {; ^6 ^% z6 i" H
- .
5 `8 d3 i$ S. I - .
9 X% v& F! ~% K4 f - limit_conn addr 5;
8 H: e! f, K2 E - .2 I( s2 E, p5 }; {2 F: z$ d# j
- .2 d5 H$ v7 v3 n+ N- d3 d% ~4 t
- }
銴鋆賭誨蝣
: }% j2 V; f) J! n4 E# g! V% {- x5 ^! T
蝺餌(瘥IP桐蝺)
$ G9 \9 `) p: [& e5 l! _3 P5 z, p9 r6 b+ _
0 l% e! a4 b- f% u" l* Z9 x g亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂
# {9 z+ f) [7 X. S- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣
# I" x. e( F( `/ p8 ^( Q# [% A2 C支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
4 W3 {5 _8 |% }
1 W6 u4 T% Y1 E1 X3 l9 t! [
; S1 w3 s' Z1 a/ M! C2 v- }嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗
' l; Q' v* s* A5 Z" {- location /download/ {4 |. j7 \+ _! L- `! [
- limit_req zone=one burst=5;4 Z W6 I3 V+ ]
- }
銴鋆賭誨蝣
3 @- y* L$ _1 g* j/ k臬 server 畾菟撠Domain銝撠銝靘桅靘園餌$ j' a% v0 y- O3 _) d: {* s
- .
* [1 R; U( M1 p, I$ s( H - .
7 {4 e& P/ \5 i - .
$ d3 U2 J; s( Q9 Z* d6 d9 o - server {7 N$ t8 `- y- p3 Q
- .
4 a+ I4 Y9 n2 H; a F' S - .4 L( y: B+ o! g: a
- <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>. h% o! v! F3 I6 r; _" Z8 W
- .
) U1 m; K7 N, u9 K2 O1 I - .
& ?% G. ~$ p) T3 I/ l7 X5 E - }
銴鋆賭誨蝣
. t; O/ u- ~2 Y" D1 p( N _) J9 |+ Z+ V) l0 w/ q# Q, Y
蝯隢:
3 Y+ y0 ?: J3 X$ S5 }- L9 h4 u5 D8 O' s& L& S6 V- r( i: U8 g! R
撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝6 V5 O3 x8 Q- f; T- w1 B+ N
8 F; d/ X% W J5 c# n' B1 L嗡隢 :' J' q/ c4 v8 x+ j
https://blog.gtwang.org/linux/ng ... address-tutorial/2/
: L+ g( H8 Q7 c5 P- rhttp://www.nginx.cn/446.html
p% f! z8 x* D1 T. x: O* _' L2 l- ]/ l( Q- p
|
|