迹忆客 EN >

当前位置:主页 > 学无止境 > 网络 >

NodeJS & HTTP 错误码 431 Request Header Fields

作者:迹忆客 最近更新:2023/02/01 浏览次数:

我最近发现来自 Node JS 微服务的错误响应带有 HTTP 错误“431 Request Header Fields Too Large”,但起初它似乎是间歇性的,取决于所使用的测试环境。 进一步的调查发现它是最大标头大小的 Node 设置以及 Node JS 版本更改和一些大型 cookie。

Error 431 Request Header Fields Too Large HTTP 错误表示请求标头(包括 cookie)的总大小太大,Web 服务器无法接受。这通常发生在大型 cookie 已建立最大化请求大小的情况下。

在 2018 年,Node(版本 11.6.0)进行了更新,以解决该领域的一个安全漏洞 — 带有大型 HTTP 标头的拒绝服务 (CVE-2018–12121),这导致默认的最大请求标头大小减少到 8kb(从16kb),有趣的是选择了 8kb,因为它是当时 NGINX 的默认值。默认限制最终在 v13.13.0 中增加到 16kb,这意味着如果大家碰巧在 11.6 和 13.13 之间的 Node 版本上运行,那么大家就会面临 8kb 的限制,但在这些版本之前或之后不会有 8kb的限制,而会有 16kb 的限制——这是我最近碰到的情况。

如果大家的 node 安装的默认最大标头大小对自己不适用的话,那么可以使用 -max-http-header-size 参数配置新值,这是很容易的。

--max-http-header-size=16250

当然,我们也不应将此值设置得太高,而应针对自己的特定应用程序将其配置的值尽可能的低。

转载请发邮件至 1244347461@qq.com 进行申请,经作者同意之后,转载请以链接形式注明出处

本文地址:

相关文章

Throwing Errors in Node.js

发布时间:2025/04/17 浏览次数:164 分类:Node.js

This article will explain how to throw errors in Node.js. Throwing Errors in Node.js Errors are statements that do not allow the system to function properly. Errors in Node.Js are handled through exceptions, which are created with the help

Solve the Cannot Find Module error in Node.js

发布时间:2025/04/17 浏览次数:70 分类:Node.js

In this article, we will learn how to fix the Cannot find module error in Node.js. package.json File Before diving into the solution, we will first try to understand the package.json file and why we need it. The package.json file is the roo

Multithreading in Node.js

发布时间:2025/04/17 浏览次数:113 分类:Node.js

In Node.js, the term multithreading does not apply because Node.js is designed to run in a single-threaded event loop. However, Node.js is built on top of the JavaScript language, which is single-threaded by default. However, Node.js provid

Using jQuery in Node.js

发布时间:2025/04/17 浏览次数:51 分类:Node.js

jQuery is a popular JavaScript library that is widely used to build web applications. It provides a rich set of APIs for interacting with the DOM, making HTTP requests, handling events, etc. Node.js is a JavaScript runtime that allows devel

Node.js sends files to the client

发布时间:2025/04/17 浏览次数:70 分类:Node.js

In this article, we will learn how to send files to the client in Node.js using Express. Sending files using Express in Node.js Express.js or Express is a backend web utility framework for Node.js. Express is a Node.js web application frame

HTTP POST request in Node.js

发布时间:2025/04/17 浏览次数:131 分类:Node.js

In this article, we will learn how to use Node.js to make a post request using a third-party package. HTTP Post Request in Node.js The HTTP POST method creates or adds resources on the server. The key difference between POST and PUT request

Reading Files in Node.js

发布时间:2025/04/17 浏览次数:138 分类:Node.js

In this short article, we will learn how to read files in Node.js. Reading Files in Node.js fs The module provides many useful functions to access and interact with the file system. fs One special feature of the module is that all methods a

Calling REST API in Node.js

发布时间:2025/04/17 浏览次数:197 分类:Node.js

REST is short for Representational State Transfer . A REST API or RESTful API is an API or Web API (Application Programming Interface) that conforms to the constraints/restrictions of the REST architectural style and allows interaction with

AJAX calls in Node.js

发布时间:2025/04/17 浏览次数:103 分类:Node.js

Representational State Transfer is abbreviated as REST . An API or Web API (Application Programming Interface) that complies with the restrictions and limitations of the REST architectural style and allows interaction with RESTful web servi

扫一扫阅读全部技术教程

社交账号
  • https://www.github.com/onmpw
  • qq:1244347461

最新推荐

教程更新

热门标签

扫码一下
查看教程更方便