上传/部署 zip 文件时,不会创建 .platform 挂钩中的 AWS Elastic Beanstalk 自定义 nginx .conf 文件

AWS Elastic Beanstalk custom nginx .conf file in the .platform hooks is not created when zip file is uploaded/ deployed

我正在将 Node JS/Express JS 应用程序部署到 AWS Elastic Beanstalk 环境。我正在创建自定义 nginx 配置文件来更改设置。为此,我创建了以下文件。

{project_root_directory}/.platform/nginx/conf.d/elasticbeanstalk/mynginx.conf

server {
    client_max_body_size 512M;
}

然后像往常一样部署应用程序,我压缩我的项目并在 AWS 控制台中上传压缩文件。环境更新后,我查看了服务器上的文件,没有。

为什么文件不存在,我该如何修复它?

详情如下:

图像是亚马逊 Linux 2 AMI。

我在根文件夹中创建了一个 .ebextensions 文件夹,其中包含以下文件:

00-files.config

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

01-nodecommand.config

option_settings:
  - namespace: aws:elasticbeanstalk:container:nodejs
    option_name: NodeCommand
    value: "npm start"

02-migrationcommand.config

option_settings:
  - namespace: aws:elasticbeanstalk:container:nodejs
    option_name: MigrationCommand
    value: "npx sequelize-cli db:migrate"

然后我再次在根文件夹中创建了 .platform/nginx/conf.d/mynginx.config 文件,内容如下。

server {
    client_max_body_size 512M;
}

所以我有这样的项目结构。

然后我压缩项目。然后登录到 AWS 控制台并转到 Beanstalk 控制台并在那里上传 zip 文件。

假设你使用的是亚马逊Linux2 EB平台,正确的文件夹应该是:

{project_root_directory}/.platform/nginx/conf.d/mynginx.conf

没有

{project_root_directory}/.platform/nginx/conf.d/elasticbeanstalk/mynginx.conf

更新:

您的 mynginx.conf 应该是:

client_max_body_size 512M;