0

I am running a nodejs website on AWS beanstalk with Nginx as proxy server.

Every time when I deploy a new version of the site, Nginx display a default 502 error page during the update, and then the site goes back to normal after the deployment complete.

Therefore, I want to customise this page with my error html.

What I did is:

  1. Upload my error.html to beanstalk ec2 instance under folder: /var/www/default

  2. Create myconf.conf in side my node project folder: .platform/nginx/conf.d with the following content:

    server { error_page 502 /error.html; location = /error.html { root /var/www/default; } }

  3. Deploy my nodejs zip package to beanstalk through aws beanstalk console

  4. Refresh the website and see if the 502 error page is showing my error.html during the update.

However, it is still showing Ngnix's default 502 error page which is: 502 Bad Gateway

Please help.

Thanks.

========= Update =========

After investigation, what I have discovered is: Every time when a new zip file is deployed to AWS beanstalk console, everything under folder: etc/ngnix/conf.d is deleted and uploaded again, therefore, the configuration file myconf.conf I uploaded via beanstalk zip file is deleted.

I tried to directly edit my configuration into Nginx configuration file /etc/nginx/nginx.conf, however, this file is also re-created by beanstalk when the zip file is uploaded.

Therefore, my guess is: As every time when the zip file is uploaded (that means I am updating my website), all my configuration is gone, therefore, my customised 502 error page is not displayed. And after the deployment is finished, my configuration becomes effective, however, as the website update is already done, therefore, there is no use of my configuration. I guess the solution might be somewhere in editing AWS beanstalk default configuration so every time when aws re-creates the configuration, my customised configuration will also be included. I have tried to editing etc/ngnix/nginx.conf.default but it seems does not work.

Zhang Zhan
  • 815
  • 8
  • 27
  • If you ssh to the EB instance, can you make the nginx changes manually to verify that your configuration work? – Marcin Dec 04 '20 at 00:50
  • Thanks for the reply @Marcin I ssh to the instance and I confirm my configuration file "myconf.conf" is deployed by beanstalk to folder: /etc/nginx/conf.d – Zhang Zhan Dec 04 '20 at 01:18

0 Answers0