由于 DDoS 攻击的目标是你的 Web 服务器,防止攻击的方法是减少到达这些服务器的请求。
flowchart TD;
A[Malicious device]-->|Request to application|CDN;
CDN -->|Sends remaining requests|Origin;
subgraph CDN
WAF
Cache
end
A --Prevent external connections---x Origin
请求可以通过两种方式到达你的源站服务器:来自你的 Web 应用程序,或直接连接到服务器本身。
缓存存储频繁访问的资源(图片、CSS 文件)的副本。
当资源被缓存时——无论是在用户的浏览器上还是在内容分发网络 (CDN) 服务器上——对该资源的请求都不必发送到你的源站服务器。相反,这些资源由缓存直接提供。
flowchart TD;
User["用户"]-->|发送请求|Cloudflare;
Cloudflare-->B>有缓存内容?];
B-->|是 - 请求的内容|User;
B-->|否|Origin["源站"];
Origin-->|请求的内容|User;
在 DDoS 攻击的语境下,缓存减少了流向源站服务器的请求数量,从而使你的服务器更难被流量淹没。
Web 应用程序防火墙 (WAF) 在 Web 应用程序和 Internet 之间建立了一道屏障。这道屏障检查传入的 Web 请求并过滤不需要的流量,以协助缓解许多常见攻击。
flowchart TD;
User-->|Sends Request|WAF;
WAF-->|Filters Request|Application;
Application-->|Sends Request|OriginServer;
OriginServer-->|Serves Content|Application;
Application-->|Serves Content|User;
通常,你的源站服务器应该仅接受来自你的 Web 应用程序的请求。
这是通用的安全最佳实践,但在 DDoS 攻击语境下尤为重要。任何绕过你 Web 应用程序的流量也会绕过任何 WAF 或缓存,并且更有可能瘫痪你的源站。
sequenceDiagram participant Client participant DDoS_Protection_Service participant Origin_Server Client->>+DDoS_Protection_Service: Request Note right of DDoS_Protection_Service: Filtered traffic DDoS_Protection_Service->>+Origin_Server: Request Origin_Server-->>-DDoS_Protection_Service: Response DDoS_Protection_Service-->>Client: Response Client->>+Origin_Server: Direct connection Note over Origin_Server: Potential DDoS Attack Origin_Server-->>-Client: Error response