如何设置 nginx 请求允许的 url 长度(错误代码:414,uri 太大)

发布于 2024-07-26 01:22:19 字数 162 浏览 4 评论 0 原文

我在 10 个杂种面前使用 Nginx。

当我发出大小大于 2900 的请求时,我会得到一个:

错误代码 414:uri 太大

有谁知道 nginx 配置文件中确定允许的 uri 长度的设置吗?

I am using Nginx in front of 10 mongrels.

When I make a request with size larger then 2900 I get back an:

error code 414: uri too large

Does anyone know the setting in the nginx configuration file which determines the allowed uri length ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

泡沫很甜 2024-08-02 01:22:19

来自:http://nginx.org/r/large_client_header_buffers

语法: large_client_header_buffers 数字 大小 <代码>;
默认: large_client_header_buffers 4 8k;
上下文: http、服务器

设置用于读取大型客户端请求标头的缓冲区的最大数量大小。 请求行不能超过一个缓冲区的大小,否则会向客户端返回 414(Request-URI Too Large)错误。 请求头字段也不能超过一个缓冲区的大小,否则会向客户端返回 400(Bad Request)错误。 缓冲区仅按需分配。 默认情况下,缓冲区大小等于 8K 字节。 如果请求处理结束后连接转换为保持活动状态,则释放这些缓冲区。

因此您需要将该行末尾的大小参数更改为更大的值以满足您的需要。

From: http://nginx.org/r/large_client_header_buffers

Syntax: large_client_header_buffers number size ;
Default: large_client_header_buffers 4 8k;
Context: http, server

Sets the maximum number and size of buffers used for reading large client request header. A request line cannot exceed the size of one buffer, or the 414 (Request-URI Too Large) error is returned to the client. A request header field cannot exceed the size of one buffer as well, or the 400 (Bad Request) error is returned to the client. Buffers are allocated only on demand. By default, the buffer size is equal to 8K bytes. If after the end of request processing a connection is transitioned into the keep-alive state, these buffers are released.

so you need to change the size parameter at the end of that line to something bigger for your needs.

So要识趣 2024-08-02 01:22:19

对于任何在 https://forge.laravel.com 上遇到此问题的人,我设法使用SO 答案的汇编;

您将需要 sudo 密码。

sudo nano /etc/nginx/conf.d/uploads.conf

将内容替换为以下内容;

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

client_max_body_size 24M;
client_body_buffer_size 128k;

client_header_buffer_size 5120k;
large_client_header_buffers 16 5120k;

For anyone having issues with this on https://forge.laravel.com, I managed to get this to work using a compilation of SO answers;

You will need the sudo password.

sudo nano /etc/nginx/conf.d/uploads.conf

Replace contents with the following;

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

client_max_body_size 24M;
client_body_buffer_size 128k;

client_header_buffer_size 5120k;
large_client_header_buffers 16 5120k;
零度℉ 2024-08-02 01:22:19

我有非常相似的问题,但有不同的错误

从上游读取响应标头时,上游发送了太大的标头

为了修复它,我已经更改了

server {
....
proxy_buffers   4 32k;
proxy_buffer_size   32k;
...
}

有关更多信息,您可以访问 nginx-doc

I had very similar issue but with a different error

upstream sent too big header while reading response header from upstream

In order to fix it I've changed

server {
....
proxy_buffers   4 32k;
proxy_buffer_size   32k;
...
}

For more information you can visit nginx-doc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文