撠潸頛瘥頛擃隡箸剁臭誑閮剖瘥銝雿雿輻刻臭蝙函鞈皞銝嚗靘憒憭折蝺詻蝺餌嚗瘥蝘瘥蝺甈⊥賂隞亙銝頛摨艾; z9 B9 \- A- c4 ?
- ]+ I: g5 B. I" U3 \' C$ _! k憭折蝺亥嗅憭折蝺賂擐閬雿輻 limit_conn_zone 摰蝢拐 key zone 賂- limit_conn_zone $binary_remote_addr zone=addr:10m;
銴鋆賭誨蝣 隤芣:% L7 w9 Z6 M0 K3 l, [
摰蝢拐 addr zone嚗蝛粹憭批 10MB嚗worker 銵蝔雿輻券 zone 蝵桃曹澈閮園蝛粹靘脣 key 閮詨潦雿輻 $binary_remote_addr 靘雿箏斗瑚皞 IP 靘嚗key嚗嚗雿輻券鈭脖霈訾雿 key 臬箏頝銝祉摮銝脫韏瑚嚗瘥頛蝛粹嚗憒 zone 蝵桃曹澈閮園蝛粹典鈭嚗隡箸典停 503嚗Service Temporarily Unavailable嚗航炊閮胯+ h, }/ {5 P. T# @5 \" R* @
! V1 ~/ h% t! y0 x' n7 a; J1 u
; d) L* e+ L. b" @9 K S5 ?6 f亥雿輻 limit_conn 摰銝 IP 臭誑閮梁憭折蝺賂
( F" p( ]4 y7 S' {" a S- location /download/ {
- I$ U v2 F$ k$ M, V( u - limit_conn addr 5;- I8 a- M1 Z1 l& l! ]
- }
銴鋆賭誨蝣
2 [ O1 Q! M5 y: ~& b, b3 L6 F n5 K$ \% o. d4 N# Q, h! p H
臬 server 畾菟撠Domain銝撠銝靘桅靘園蝺! C( w! x* }9 V4 {
- .
4 f/ |" J8 z7 V - .
; m1 \: ~; T7 J" T' @0 S# e) x4 } f - .
: r/ P1 w; ~5 s% S. [1 j$ H - server {3 }3 V) I- l) K' ?* D
- .
. X3 j% C" H1 [ - .
3 z1 b. L; V) o+ w - limit_conn addr 5;
& P( c% d7 ?7 w4 ~2 @3 [ - .
+ d% L8 b i3 m7 s - .* R' \) w9 w# @$ H( Z% `
- }
銴鋆賭誨蝣
$ ?5 S2 F+ x7 A% e: e) k( o0 I2 X. t' y4 ?5 ~
蝺餌(瘥IP桐蝺)
4 S6 Z& F Q. [6 a. ~; g2 y3 w+ B5 O% Q, u
2 L8 R& u' s% ^9 E7 M) h; q, U
亥園蝺餌嚗擐銋臭璅閬 limit_req_zone 摰蝢 key zone 賂% ?) y3 K2 d! K9 b I4 s6 H' n9 f; C
- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
銴鋆賭誨蝣 ( _+ t! H5 k( t5 m
支摰蝢 zone 蝔梯憭批銋憭嚗銝鈭銝 rate 摰蝺餌銝嚗桐臭誑雿輻冽蝘蝺甈⊥賂r/s嚗舀蝺甈⊥賂r/m嚗嚗r盍equest嚗靘憒亥摰瘥銝航 30 甈⊿蝺嚗閮剖 30r/m
% {/ ~# j' e5 g; r& h h. M
* x' K) d8 [# J& U" R9 |0 N) \" W- X3 P+ p U& B
嗅券閬園蝺餌唳孵銝 limit_req 閮剖嚗1 ^. C# W% K" t. D: I
- location /download/ {
7 _% h5 l* k/ P) l- u - limit_req zone=one burst=5;
4 T9 q* G d: x5 s( B/ C - }
銴鋆賭誨蝣 , r1 h$ L4 s) U
臬 server 畾菟撠Domain銝撠銝靘桅靘園餌 I7 h0 R0 J+ y" y) C! Y+ R! X
- .
5 ?% n2 T: M, G - .
/ I1 u3 [8 c) y O) |: k) f - .
( e- E& Y: K9 s - server { u w% n E( e3 y9 v c% d
- ./ F5 j/ ^7 M: c" f3 D
- .
; Q D8 l2 R1 g- y% H% H - <span style="font-family: Tahoma;">limit_req zone=one burst=5;</span>
; Y2 _# [8 z7 e9 R - .
- E$ Z) }1 `/ o4 `" e - .8 c: L3 G% `$ y; P3 u
- }
銴鋆賭誨蝣
' n) [4 F5 B. f9 m7 s: W4 c, P/ o" P% C
蝯隢:+ G4 u3 j; x8 h5 M% x1 m% v
& S* i2 z: D4 T+ F( Y8 y+ f( U撠潔誑銝閮剖臭誑脫迫擏剖恥餅隞亙鈭敹銋敺閰血瘨雿∠餃祝
! k* H+ D; p1 [5 [' C* L4 @" E+ p5 y3 Y
嗡隢 :
' `0 b }4 t/ X; Y$ \6 @https://blog.gtwang.org/linux/ng ... address-tutorial/2/
( z* x, E" G5 I6 X" Khttp://www.nginx.cn/446.html- W. H- z- U4 Y! B. `0 q4 X1 g& N+ |5 V
' n) z" m0 d, J& h! C4 ` |
|