Beanstalk puts the nginx conf file into the wrong directory

Viewed 32

I followed the documentation so to replace the default nginx.conf file. So the tree looks like this:

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

Although everything seems correct, after the deploy, the configuration ends up being moved from .platform to /var/proxy/staging; the eb-engine.log, in facts, reports this:

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

This means that the real config file /etc/nginx/nginx.conf is still the default one.

1 Answers

You can find the answer in the AWS documentation

  • /var/app/staging/ – Where application source code is processed during deployment.
  • /var/app/current/ – Where application source code runs after processing.

When a new code version is deployed, /var/app/staging will be used to run build commands and test the settings. It is also used to test the nginx config file. If the deployment goes through, the code in /staging will be moved to /current and the nginx config will be moved to /etc/nginx/nginx.conf.

/etc/nginx/nginx.conf is the active config file. You can see this by using nginx -t.

[ec2-user@ip-172-31-1-161 ~]$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

However, the content of /etc/nginx/nginx.conf is NOT the default config. Whatever you put in /.platform/nginx/nginx.conf of your app directory will end up in /etc/nginx/nginx.conf.

In eb-engine.log you can see the config check in staging. If successful, you will see the cp command that copies the file(s) to /etc/nginx:

2022/09/07 14:23:03.027695 [INFO] Running command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf
2022/09/07 14:23:03.078615 [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/07 14:23:03.078683 [INFO] Running command /bin/sh -c cp -rp /var/proxy/staging/nginx/* /etc/nginx
Related