【问题标题】:Modify nginx config file in Elasticbeanstalk to increase body size not taking effect修改 Elasticbeanstalk 中的 nginx 配置文件以增加 body size 不生效
【发布时间】:2022-09-24 09:07:56
【问题描述】:

我需要将大文件上传到服务器(其中一些达到 1GB)并且我收到此错误:

<html>

<head>
    <title>413 Request Entity Too Large</title>
</head>

<body>
    <center>
        <h1>413 Request Entity Too Large</h1>
    </center>
    <hr>
    <center>nginx/1.20.0</center>
</body>

</html>

我知道这个错误来自nginx,我需要增加

client_max_body_size

我创建了一个具有以下结构的 .ebextensions 文件夹:

.ebextensions/nginx/conf.d/proxy.conf

我还创建了一个具有相同结构的 .platform 文件夹

.platform/nginx/conf.d/proxy.conf

proxy.conf 包含:

client_max_body_size 999M;

在这样做并部署它之后,它会不断抛出相同的错误。

平台(由弹性豆茎创建)是

Linux/UNIX

我可以在日志(eb-engine.log)中看到这一点,但我不确定这是否是因为我做了什么:

2022/09/22 11:00:35.780593 [INFO] 执行指令:启动代理 使用新配置 2022/09/22 11:00:35.780613 [INFO] 正在运行 命令 /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf 2022/09/22 11:00:35.803451 [信息] nginx:配置文件/var/proxy/staging/nginx/nginx.conf 语法没问题 nginx: 配置文件 /var/proxy/staging/nginx/nginx.conf 测试成功

谢谢!

    标签: amazon-web-services nginx amazon-elastic-beanstalk nginx-reverse-proxy


    【解决方案1】:

    你应该使用.platform,而不是.ebextensions。例如:

    .platform/nginx/conf.d/myconfig.conf

    client_max_body_size 999M;
    

    【讨论】:

    • 我忘了说我也尝试过 .platform ,我会更新我的问题。但是,我会仔细检查。
    • 是啊,老是说一样的。。
    【解决方案2】:

    对于任何面临同样问题的人。我实际上做得很好,但我错过了在构建步骤中将 .platform 文件夹移动到 dist/ 文件夹。 所以我只是做了:

    - cp -R .platform/ dist/.platform
    

    在后期构建步骤中。

    【讨论】:

      猜你喜欢
      • 2021-05-06
      • 2020-12-14
      • 2014-01-25
      • 2018-05-18
      • 2014-01-18
      • 2020-04-16
      • 2019-10-27
      • 2017-05-29
      • 1970-01-01
      相关资源
      最近更新 更多