如何在弹性beantalk中扩展nginx配置

如何在弹性beantalk中扩展nginx配置

本文介绍了如何在弹性beantalk中扩展nginx配置(Amazon Linux 2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了此处的建议配置Nginx反向代理以允许大于默认1mb的文件.所以,我的代码在/.platform/nginx/conf.d/prod.conf 看起来像这样:

I followed the advice here to configure the nginx reverse proxy to allow files larger than the default 1mb. So, my code in/.platform/nginx/conf.d/prod.conflooks like this:

http {
  client_max_body_size 30M;
}

但是,这似乎没有任何作用,当我尝试上传大于1mb的文件时,nginx仍然会报错.

However, this seems to have no effect, and nginx still registers an error when I try to upload a file larger than 1mb.

我还尝试了在没有 http 和花括号的情况下执行此操作,如对,例如:

I also tried doing this without the http and braces, as detailed in the accepted answer to this question, like this:

client_max_body_size 30M;

这也没有效果.

我认为应用配置后可能需要重新启动nginx,因此我在.ebextensions目录中添加了一个名为 01nginx.config 的文件,该文件如下所示:

I thought it might be necessary to restart nginx after applying the configuration, so I added a file in the .ebextensions directory called 01nginx.config, which looks like this:

commands:
  01_reload_nginx:
    command: "sudo service nginx reload"

这也没有效果.

我看过这个问题和上面提到的问题,以及.但是,它们似乎都已过时或不适用于Amazon Linux 2实例,因为它们均未提及上述弹性beantalk文档中的 .platform 目录.无论如何,到目前为止,他们的答案都没有对我有用.所以,我想念什么?

I have seen this question and the above-referenced question, as well as this one. However, they all seem either outdated or non-applicable to an Amazon Linux 2 instance, since none of them mention the .platform directory from the above-referenced elastic beanstalk documentation. In any case, none of their answers have worked for me thus far. So, what am I missing?

推荐答案

好吧,经过多次尝试,我能够这样解决:

Ok, after many tries, I was able to solve this like so:

在.ebextenstions目录中添加一个名为 01_reverse_proxy.config 的文件(名称无关紧要,只是我认为的.config部分)

Add a file in the .ebextenstions directory called 01_reverse_proxy.config (name doesn't matter, just the .config part I think)

在该文件中,完全放置以下内容:

In that file, place exactly this:

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

具有适当的YAML间距.这解决了包括Rails,Puma和Amazon Linux 2.11.4在内的堆栈上的问题.这不是弹性beantalk linux平台中记录的方式文档.

with proper YAML spacing. This solves the problem on a stack including Rails, Puma, and Amazon Linux 2.11.4. This is NOT the way documented in the elastic beanstalk linux platforms documentation.

这篇关于如何在弹性beantalk中扩展nginx配置(Amazon Linux 2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 08:26