首页 文章

无法增加client_max_body_size

提问于
浏览
0

过去几天我一直在努力增加nginx的上传限制,这与我的弹性beanstalk实例不同 . 根据我的理解,我需要一个ebextensions文件来设置client_max_body_size . 我尝试了几种不同的配置方式,比如直接覆盖nginx.conf以在live服务器上的nginx.conf中插入client_max_body_size . 这些方法都没有奏效 . 我确定在每次尝试后手动重新加载文件 . 就目前而言,这就是我的配置文件目前的样子(经过几次迭代):

.ebextensions / 01_nginx.config

files:
  /etc/nginx/conf.d/proxy.conf:
    content: |
      client_max_body_size 2G;

如果有人能帮助我那将是非常棒的 .

1 回答

  • 0

    您可以扩展它或覆盖它 .

    Elastic Beanstalk提供了一个默认的nginx配置,您可以使用自己的配置完全扩展或覆盖它

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

    Source

    与文档中的示例相比,您的配置与您的问题相符 . 通过sshing验证你的nginx conf的位置

    $ eb ssh environment-name
    $ sudo service nginx configtest
    nginx: the configuration file /${LOCATION}/nginx.conf syntax is ok
    nginx: configuration file /${LOCATION}/nginx.conf test is successful
    

    Doc示例

    "/home/ec2-user/myfile2" :
        content: |
          # this is my file
          # with content
    

    如果你有正确的nginx配置路径,也可以尝试将nginx重新加载添加到.ebextensions .

    files:
      /etc/nginx/conf.d/proxy.conf:
      mode: "000644"
      owner: root
      group: root
      content: |
          client_max_body_size 2G;
    
    commands:
      01_reload_nginx:
        command: "sudo service nginx reload"
    

    Source

    Helpful blog post that runs thru most of this: "Getting to Know and Love AWS Elastic Beanstalk Configuration Files"(.ebextensions)

相关问题