gpt4 book ai didi

amazon-web-services - 增加 AWS Elastic Beanstalk 上 Nginx conf 中的 client_max_body_size

转载 作者:行者123 更新时间:2023-12-03 04:43:35 24 4
gpt4 key购买 nike

将大于 10MB 的文件发布到在 AWS Elastic Beanstalk 上运行的 API 时,我遇到了“413 请求实体太大”错误。

我已经做了相当多的研究,并相信我需要增加 Nginx 的 client_max_body_size,但是我似乎找不到任何有关如何使用 Elastic Beanstalk 执行此操作的文档。我的猜测是需要使用 ebetension 文件对其进行修改。

有人知道如何提高限​​制吗? 10MB 相当弱,必须有办法手动增加。

最佳答案

为此,您可以采取两种方法。不幸的是,有些适用于某些 EB 应用程序类型,有些适用于其他类型。

AWS 文档中支持/推荐

对于某些应用程序类型,例如Java SE , Go , Node.js ,也许还有 Ruby(没有针对 Ruby 的文档,但所有其他 Nginx 平台似乎都支持这一点),Elasticbeanstalk 对如何配置 Nginx 有内置的了解。

To extend Elastic Beanstalk's default nginx configuration, add .conf configuration files to a folder named .ebextensions/nginx/conf.d/ in your application source bundle. Elastic Beanstalk's nginx configuration includes .conf files in this folder automatically.

~/workspace/my-app/
|-- .ebextensions
| `-- nginx
| `-- conf.d
| `-- myconf.conf
`-- web.jar

Configuring the Reverse Proxy - Java SE

要专门增加最大上传大小,请在 .ebextensions/nginx/conf.d/proxy.conf 创建一个文件,将最大正文大小设置为您想要的任何大小:

client_max_body_size 50M;

直接创建Nginx配置文件

对于其他一些应用程序类型,经过大量研究并与出色的 AWS 支持团队一起工作数小时,我在 .ebextensions 内创建了一个配置文件来补充 nginx 配置。此更改允许更大的帖子主体尺寸。

.ebextensions 目录中,我创建了一个名为 01_files.config 的文件,其中包含以下内容:

files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;

这会在/etc/nginx/conf.d 目录中生成一个 proxy.conf 文件。 proxy.conf 文件仅包含一行 client_max_body_size 20M; 即可实现这一目的。

请注意,对于某些平台,此文件将在部署期间创建,但会在稍后的部署阶段删除。

您可以指定 Nginx 文档中概述的其他指令。

http://wiki.nginx.org/Configuration

关于amazon-web-services - 增加 AWS Elastic Beanstalk 上 Nginx conf 中的 client_max_body_size,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18908426/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com