3

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.

Federico Loro
  • 65
  • 1
  • 6

1 Answers1

0

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
hurb
  • 2,177
  • 3
  • 18
  • 32
  • That's ok, I know this. After the deploy, I can find the updated app into `/var/app/current`. The nginx conf **is not** copied into `/etc/nginx` tho, but into `/var/proxy/staging` and I don't know why. The configuration is correct, since if I replace the default one with the one I made it works as it should. At the moment I addedd another postdeploy scripts that copies the custom conf into `/etc/nginx` and restarts the nginx service, although I'd like beanstalk to do this. – Federico Loro Sep 08 '22 at 13:17
  • I just tested this again. My `/.platform/nginx/nginx.conf` gets copied to `/etc/nginx/nginx.conf` every time I deploy (if the deployment is successful) without any custom scripts. So, like I said, it's not the default config in `/etc/nginx/nginx.conf`, it should be your custom config. I would check the logs again and see if there are any issues with the new version (if staging fails it won't be copied). – hurb Sep 08 '22 at 15:40
  • As I said, these are the only logs about nginx: `2022/09/08 14:10:55.739998 [INFO] Executing instruction: configure proxy Nginx 2022/09/08 14:10:55.741043 [INFO] Running command /bin/sh -c cp -rp /var/app/staging/.platform/nginx/. /var/proxy/staging/nginx` The nginx conf is correct. – Federico Loro Sep 09 '22 at 08:15
  • Understood. Does it run the config check `/usr/sbin/nginx -t -c` as shown in my `eb-engine.log`? If it gets to that point you should see the `cp -rp /var/proxy/staging/nginx/* /etc/nginx` as well. Just trying to figure out where this fails because if the deployment is successful it should eventually get to the point where it copies the staging config to `/etc/nginx` as you can see in my logs. – hurb Sep 09 '22 at 19:57