[Elastic Beanstalk] Nginx configuration is not being copied to /etc/nginx


As the title sais, the configuration files of nginx are not being copied from /var/proxy/staging to /etc/nginx as it should (maybe?). I have followed the documentation about overwritiing the default nginx conf, so this is my bundle tree:

├─ .platform/
│  ├─ nginx/
│  │  ├─ nginx.conf
│  │  ├─ conf.d/
│  │  │  ├─ my_custom_conf.conf

Unfortunantely the files are copied to /var/proxy/staging and not copied to /etc/nginx. The configuration file is correct (I also manually copied to /etc/nginx and restarted the webserver and it works). If I press "environment rebuild" from the beanstalk console, the new instance won't even start nginx automatically. I had to make another postdeploy script to move the files and restart nginx. In the eb-engine.log logs there's nothing beside the copy command:

Running command /bin/sh -c cp -rp /var/app/staging/.platform/nginx/. /var/proxy/staging/nginx

I have other applications where this works fine. I can't find the solution.

profile picture
asked 3 months ago53 views
1 Answer


Thank you for posting your query on re:Post. As I understand, you are facing issue configuring the Nginx proxy, however the changes are not copying to the desired location.

As per the directory structure is concerned, the one you mentioned seems correct to me. Based on the documentation, the .platform directory should be at the root of the source bundle.

[] Extending Elastic Beanstalk Linux platforms - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

Now, since this is working on other applications, there is something specific to your current application which is causing the issue. Therefore, is it possible for you reach out to AWS Support via the support case (for privacy concerns) for further troubleshooting on the issue.

Please share the complete bundle logs, details of the environment like environment name or id. for more insights.

Further on the copy command, the command is executed after the nginx configuration is validated. Please refer the below logs for my replication.

2022/09/12 14:32:07.721209 [INFO] Executing instruction: start proxy with new configuration

2022/09/12 14:32:07.721232 [INFO] Running command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf

2022/09/12 14:32:07.731058 [INFO] nginx: the configuration file /var/proxy/staging/nginx/nginx.conf syntax is ok

nginx: configuration file /var/proxy/staging/nginx/nginx.conf test is successful

2022/09/12 14:32:07.731356 [INFO] Running command /bin/sh -c cp -rp /var/proxy/staging/nginx/* /etc/nginx

Therefore, can you please check if in the logs you are getting anything apart from the log entry you mentioned.

Hoping that the above helps. Thank you.

answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions