I deployed the app on Amazon Linux 2 and it seems to be okay except for the part where when I try to access the environment URL it gives the 502 Bad Gateway
error.
Here are my .ebextensions
which I used:
01_packages.config
packages:
yum:
git: []
postgresql-devel: []
libjpeg-turbo-devel: []
commands:
setuptools:
command: pip install setuptools --upgrade
db-migrate.config
container_commands:
01_migrate:
command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: multitennant_v2.settings
django.config
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: multitennant_v2/wsgi.py
I am not sure how and where to define the nginx commands.
I accessed the nginx error logs and it shows the following:
2021/12/29 05:59:11 [error] 691#691: *43880 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.220, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.8.112"
2021/12/29 05:59:17 [error] 691#691: *43882 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.39.27, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.8.112"
The problem was with djngo.config
file
instead of the above it should be :
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: multitennant_v2.wsgi:application
Source: Deploy a django application