Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

The Ultimate Node.js Production Checklist #612

Merged

Conversation

luojiyin1987
Copy link
Contributor

@luojiyin1987 luojiyin1987 commented Feb 19, 2022

Checklist:

Closes #611

@luojiyin1987
Copy link
Contributor Author

#611

@miyaliu666 miyaliu666 added the Review-awaiting 待校对 label Feb 22, 2022

![The Ultimate Node.js Production Checklist](https://www.freecodecamp.org/news/content/images/size/w2000/2020/03/screely-1585049597841.png)

Are you doing this Node thing right on production? Let's see some common mistakes people make running Node on production (coming straight from my own projects - like [codedamn](https://codedamn.com)) and how they can be mitigated.
你在生产环境中做对了Node这件事吗?让我们看看人们在生产环境中运行Node的一些常见错误(直接来自我自己的项目--如[codedamn](https://codedamn.com)),以及如何减轻它们。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你在生产中是否正确使用 Node?
以及如何减少这些错误


But the least you can do is prevent a script-kiddie from taking down your server just because you have an expensive API endpoint exposed from your server without any rate-limiting in place.
但是,你至少可以防止一个脚本小子对你的服务器上有一个系统开销昂贵的API端点(endpoints)进行攻击,因为没有任何速率限制,导致你的服务器瘫痪。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但是,你至少可以防止一个脚本小子对你的服务器上暴露的一个昂贵的、没有设置任何速率限制的 API 端点进行攻击,从而导致你的服务器瘫痪。

1. 每一个请求尝试都会被记录下来,包括IP地址/请求方式/访问路径,基本上可以记录尽可能多的信息(当然,密码和信用卡信息等私人信息除外)
2. 这可以通过[morgan](https://www.npmjs.com/package/morgan)软件包实现。
3. 在生产中设置**文件流日志(file stream logs)**,而不是控制台输出。这更快,更容易看到,并允许你将日志导出到在线日志查看服务。
4. 不是所有的日志信息都有同等的权重。有些日志只是用来调试的,而如果有些日志出现了,则可能预示着出现了裤衩的情况(比如服务器被黑或未经授权的访问)。使用winston-logger来记录不同级别的日志。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是所有的日志信息都具有同等重要性。有些日志只是用来调试的,而如果有些日志出现了,则可能预示着火烧眉毛的情况(如服务器被黑或未经授权的访问)。使用 winston-logger 可记录不同级别的日志。

@miyaliu666 miyaliu666 merged commit c66e8c6 into freeCodeCamp:main Dec 27, 2023
@miyaliu666 miyaliu666 added Published 已发布 and removed Review-awaiting 待校对 labels Dec 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Published 已发布
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Auto]( 终极 Node.js 生产环境检查清单)
2 participants