【问题标题】:How to resolve error 413 Request Entity Too Large in Nginx and Amazon ElasticBeanstalk?如何解决 Nginx 和 Amazon ElasticBeanstalk 中的错误 413 Request Entity Too Large?
【发布时间】:2015-03-17 19:39:21
【问题描述】:

我在项目中上传大图像时遇到问题,我的配置是 puma 和 RoR。我在 elasticbeanstalk 中的用户是 ec2-user。

我已经尝试了许多我看到的配置,但它无法正常工作。 .ebextensions 中的文件是这样的:

files:
  "/etc/nginx/conf.d/proxy.conf" :
    mode: "000777"
    owner: root
    group: root
    content: |
        client_max_body_size 4G;

其他配置但不起作用

files:
  "/etc/nginx/conf.d/proxy.conf" :
    mode: "000755"
    owner: ec2-user
    group: ec2-user
    content: |
        client_max_body_size 50M;

文件已创建但没有成功。有什么建议?谢谢。

【问题讨论】:

标签: ruby-on-rails amazon-web-services nginx amazon-ec2 amazon-elastic-beanstalk


【解决方案1】:

我已经用这个文件解决了这个问题:.ebextensions/01_files.config

container_commands:
  01_reload_nginx:
    command: "service nginx reload"
files:
    "/etc/nginx/conf.d/proxy.conf":
      mode: "000755"
      owner: root
      group: root
      content: |
        client_max_body_size 0;

【讨论】:

    【解决方案2】:

    我已经解决了我的问题,我必须在http中添加:client_max_body_size

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

    【讨论】:

    • 需要重启nginx吗?如果是这样,你是怎么做到的?
    • 你需要再次部署,你可以使用命令行:eb deploy
    • 无需再次部署,因为它可能无法在流量大时附加的新实例上运行。使用thanhquang1988的另一个答案
    猜你喜欢
    • 1970-01-01
    • 2021-07-28
    • 2013-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多