简体   繁体   中英

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

I am deploying a Node JS/ Express JS application to AWS Elastic Beanstalk environment. I am creating custom nginx config file to change a setting. To do that I created the following file.

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

server {
    client_max_body_size 512M;
}

Then to deploy the application as usual, I zip my project and upload the zip in the AWS console. After the environment is updated, I checked the file on the server and it is not there.

在此处输入图像描述

Why the file is not there and how can I fix it?

The following are the details:

Image is Amazon Linux 2 AMI.

I created a .ebextensions folder right inside the root folder with the following files:

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"

Then again I created .platform/nginx/conf.d/mynginx.config file right inside the root folder with the following content.

server {
    client_max_body_size 512M;
}

So I have the project structure like this.

在此处输入图像描述

Then I zip the project. Then login to the AWS console and go to the Beanstalk console and upload the zip file there.

在此处输入图像描述

Assuming that you are using Amazon Linux 2 EB platform, the correct folder should be:

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

not

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

Update:

Your mynginx.conf should be:

client_max_body_size 512M;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM