search
HomeWeb Front-endJS TutorialWhat is a DDos attack? How does the node SSR service prevent and handle attacks?

What is a DDos attack? node How does the SSR service prevent and deal with DDos attacks? The following article will take you to understand DDos attacks, and introduce how the node SSR service prevents and handles DDos attacks. I hope it will be helpful to everyone!

What is a DDos attack? How does the node SSR service prevent and handle attacks?

Preventing and dealing with DDos attacks is an important part of stability construction. If it is not prevented in advance, once it is attacked, the service will fall into an unavailable state. , may bring great losses to the business

This article will be biased towards the node ssr service perspective, front-end development students should pay more attention to this aspect. [Related tutorial recommendations: nodejs video tutorial]

What is a DDos attack?

To give a common example, our website can be compared to a bank. Under normal circumstances, the bank can handle the business of up to 100 people at the same time. Normally, you can just walk into the bank and get a number. Can be served

Suddenly a rogue organization wanted to collect protection fees, but the bank refused to give it, so the rogue sent 3,000 or even 30,000 people to get the number at the same time. After passing the number, continue to take the number. The result is that the server cannot handle it, and a large number of normal customers have been waiting. This is a DDOS attack. It initiates a large number of requests in a short period of time, exhausts the server's resources, and is unable to respond to normal access, causing the website to actually degrade. Wire.

DDOS is not an attack, but a general term for a large class of attacks. There are dozens of types, and new attack methods are constantly being invented. Every aspect of website operation can be a target of attack. As long as one link is broken and the entire process cannot run, the purpose of paralyzing the service will be achieved.

Among them, one of the more common attacks is the cc attack. CC attacks are targeted at web pages. CC attacks themselves are normal requests. Normal requests for dynamic pages on the website will also interact with the database. When this "normal request" reaches a certain level, the server will not be able to respond. , thereby collapsing.

baike.baidu.com/item/cc�%…

The following content of this article is aimed at cc attacks.

How to prevent?

First understand the path between a request coming to our services

What is a DDos attack? How does the node SSR service prevent and handle attacks?

Business service cluster as For the bottom layer and core assets of the service link, complete upper-layer protection is very important

After intercepting malicious traffic in the outer layer, the business cluster does not need frequent operation and maintenance (capacity expansion and contraction, limit flow, etc.), reducing operation and maintenance costs
  • The business cluster does not need to prepare too many additional resources to attack traffic, saving costs
  • It has good versatility and is easy to be transplanted to other services, bringing To stabilize the income
The prevention methods are also introduced in this order

    Access to the CDN layer
  • nginx current limit
  • Connect to WAF firewall
  • Other protection layers
  • Improve the processing capabilities of the origin site.
  • For the SSR service, there are 2 suggestions


      Let the SSR service only handle the return of the root HTML, and all other resources must be placed on the CDN
    • When an attack occurs, temporarily downgrade SSR to CSR
1. Access the CDN layer

The CDN layer will be the outermost layer, which is convenient for emergency situations. You can enable CDN caching or enable CDN paid projects to protect the security of other internal services. For example:

    For example, if instantaneous traffic of millions, tens of millions or more comes in, it is possible that the load balancing layer will be down, which will affect the entire company's business. , it’s not just the service that was attacked
  • CDN’s protection capabilities include: CDN cache, Robot detection, IP reputation database, and building a custom protection rule set (combined with historical attacks Features and business forms), etc. (enabled by paid level)
  • Another aside (personal opinion), CDN vendors have countless servers around the world, and large CDN vendors can almost against all attacks, and will also charge according to the protection level (protection fee). I personally think that some attacks are probably caused by CDN vendors colluding with illegal companies. It is equivalent to rogues charging protection fees. If they don’t pay the protection fees, they will smash the store (attack) to let you know the pain, and then buy CDN protection services. And it can activate more than tens of millions of QPS. Except for CDN manufacturers (which have many servers), it should be difficult for ordinary people

#

2. nginx current limit

3. Connect to WAF firewall

Let’s talk about these two together, which is also biased The operation and maintenance level is company-level infrastructure, and the specific access methods and specific configurations vary from company to company. I won’t go into detail here

What is nginx current limit?

  • You can search by yourself

What is a WAF firewall?

To summarize the WAF layer, it will pass the pre- Set up a rich reputation database to detect and intercept threats such as malicious scanners, IPs, and cyberhorses

  • Comprehensive attack protection: supports SQL injection, XSS cross-site scripting, Detect and intercept threats such as file inclusion, directory traversal, sensitive file access, command\code injection, web Trojan upload, third-party vulnerability attacks, etc.

  • Human-computer recognition

  • Interface speed limit, WAF can set a flexible speed limit policy based on IP or cookie

  • Based on a rich combination of fields and logical conditions, precise control

    • Supports rich field conditions: based on common HTTP parameters and fields such as IP, URL, Referer, User-Agent, Params, etc. Condition combination.
    • Supports a variety of conditional logic: supports logical conditions such as inclusion, not inclusion, equal, not equal, prefix equal, prefix not equal, etc., and sets blocking or releasing policies.

#4. Other protective layers

Different companies may have other protection layers corresponding to different businesses and their own characteristics. Protection layer, such as overload protection for single instances (determine whether the current service status is overloaded, and then dynamically discard some low-priority requests based on the priority of the traffic to ensure the normal operation of the service as much as possible)

There are many kinds of protective layers here. If you are interested, you can learn more about it

5. Improve the processing capabilities of the origin station

Forging iron requires one's own hard work What is a DDos attack? How does the node SSR service prevent and handle attacks?

This is easy to understand. Improving the processing capacity of the service will naturally allow it to handle more traffic.

For SSR services, there are several suggestions as follows

Suggestion 1: Let the ssr service only handle the return of the root HTML, and all other resources must be placed on the CDN

For the ssr service, it is very important to give a Suggestions

  • Let the ssr service only handle the return of the root HTML, and all other resources must be placed on the CDN

  • Here It is easy to understand if we take juejin as an example. We can see from the figure below that juejin itself is also an SSR service. The origin site only processes the root HTML, and all other resources (js, css, pictures, fonts, etc.) are placed in on CDN. The purpose of this is also to improve the processing capabilities of the origin site, which puts a lot of pressure on the CDN

What is a DDos attack? How does the node SSR service prevent and handle attacks?

Suggestions 2: When an attack comes, temporarily downgrade SSR to CSR

What is a DDos attack? How does the node SSR service prevent and handle attacks?

SSR rendering is more CPU-intensive (requires compilation and parsing to generate HTML) , so the QPS capability of the ssr service is not high. It is easy to be defeated when facing attacks

Solution: Temporarily downgrade SSR to CSR

How to downgrade SSR?

  • Downgrade to CSR (client-side rendering), so that there is no need to generate complex HTML on the server side, and only need to return simple HTML.

    CSR is a single-page application. The simplest example is the UI component library. As you can see in the picture below, this HTML is very simple and static. Returning this static HTML does not consume much server resources.

What is a DDos attack? How does the node SSR service prevent and handle attacks?

  • And you can also cache the root HTML file in memory, which can increase the processing power of the server. Improved dozens or even hundreds of times

I will write about how to achieve SSR downgrade in a later article

6. Others

For example, there may be elastic expansion and contraction capabilities, which can only resist small traffic attacks

How to deal with emergency situations after being attacked?

has been attacked, and the service has started to be very slow, or even directly blocked. At this time, it is too late to optimize the code layer, and can only do some configurations at the operation and maintenance layer

I mainly list the following three points here, welcome to add

  • Expansion

  • Upgrade protection strategy

  • Enable CDN caching

1. Capacity expansion

can only deal with small traffic attacks

2. Upgrade protection strategy

This is a bit involving business secrets... I don’t dare to write about it. Friends who are interested can search for it by themselves, or ask about the company’s operation and maintenance

Anyway, there is one thing I guessed. Generally, after paying money to the CDN, there may not be attacks later. Even if there are, they may only be attacks with small traffic and easy to protect.

3. Turn on CDN caching

ssr service, if the CDN cache is not turned on during normal access, you can temporarily turn on the CDN cache when it is attacked.

Summary

  • The sooner you take preventive measures, the better. Don’t start taking them only after you are attacked, because a lot of losses may have already been caused.

  • Only when you have done what you need to do and answered what needs to be done, you will have room to operate the configuration when you are actually attacked. Otherwise, you can only pray to God to attack quickly. Stop... Or you can only passively accept blackmail

Safety is no trivial matter, may the world be peaceful

For more node-related knowledge, please visit:nodejs tutorial !

The above is the detailed content of What is a DDos attack? How does the node SSR service prevent and handle attacks?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:掘金社区. If there is any infringement, please contact admin@php.cn delete
node、nvm与npm有什么区别node、nvm与npm有什么区别Jul 04, 2022 pm 04:24 PM

node、nvm与npm的区别:1、nodejs是项目开发时所需要的代码库,nvm是nodejs版本管理工具,npm是nodejs包管理工具;2、nodejs能够使得javascript能够脱离浏览器运行,nvm能够管理nodejs和npm的版本,npm能够管理nodejs的第三方插件。

Vercel是什么?怎么部署Node服务?Vercel是什么?怎么部署Node服务?May 07, 2022 pm 09:34 PM

Vercel是什么?本篇文章带大家了解一下Vercel,并介绍一下在Vercel中部署 Node 服务的方法,希望对大家有所帮助!

node爬取数据实例:聊聊怎么抓取小说章节node爬取数据实例:聊聊怎么抓取小说章节May 02, 2022 am 10:00 AM

node怎么爬取数据?下面本篇文章给大家分享一个node爬虫实例,聊聊利用node抓取小说章节的方法,希望对大家有所帮助!

node导出模块有哪两种方式node导出模块有哪两种方式Apr 22, 2022 pm 02:57 PM

node导出模块的两种方式:1、利用exports,该方法可以通过添加属性的方式导出,并且可以导出多个成员;2、利用“module.exports”,该方法可以直接通过为“module.exports”赋值的方式导出模块,只能导出单个成员。

安装node时会自动安装npm吗安装node时会自动安装npm吗Apr 27, 2022 pm 03:51 PM

安装node时会自动安装npm;npm是nodejs平台默认的包管理工具,新版本的nodejs已经集成了npm,所以npm会随同nodejs一起安装,安装完成后可以利用“npm -v”命令查看是否安装成功。

聊聊V8的内存管理与垃圾回收算法聊聊V8的内存管理与垃圾回收算法Apr 27, 2022 pm 08:44 PM

本篇文章带大家了解一下V8引擎的内存管理与垃圾回收算法,希望对大家有所帮助!

node中是否包含dom和bomnode中是否包含dom和bomJul 06, 2022 am 10:19 AM

node中没有包含dom和bom;bom是指浏览器对象模型,bom是指文档对象模型,而node中采用ecmascript进行编码,并且没有浏览器也没有文档,是JavaScript运行在后端的环境平台,因此node中没有包含dom和bom。

聊聊Node.js path模块中的常用工具函数聊聊Node.js path模块中的常用工具函数Jun 08, 2022 pm 05:37 PM

本篇文章带大家聊聊Node.js中的path模块,介绍一下path的常见使用场景、执行机制,以及常用工具函数,希望对大家有所帮助!

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!