Trying to deploy django app to AWS EC2 instance using Gunicorn and Nginx

0 votes

I'm trying to deploy a Django app on AWS EC2 and also using gunicorn and Nginx in the process, I followed this tutorial link. I'm not sure what is going wrong, this is the first time I've used AWS EC2, when I try to launch the IP address of the instance it comes back as:

"can't open the page because Safari can't establish a secure connection to the server".

In my AWS console the EC2 'instance state' shows it's running.

It has been set up in ubuntu 18.04, I've also set up security groups in my EC2 instance with HTTP, HTTPS, 443, 80, 8000, 5432, and 22 all allowed from any IP address except the 22 which only has my IP address as access. Also in my Django app settings 'ALLOWED_HOSTS', I've added the instance IP address and also '*'.

this is my gunicorn.socket file:

[Unit]

Description=gunicorn socket

[Socket]

ListenStream=/run/gunicorn.sock

[Install]

WantedBy=sockets.target

and my gunicorn service file:

[Unit]

Description=gunicorn daemon

Requires=gunicorn.socket

After=network.target

[Service]

User=djangoadmin

Group=www-data

WorkingDirectory=/home/ubuntu/djangoapp1 /

ExecStart=/home/djangoadmin/pyapps/venv/bin/gunicorn \

--access-logfile - \

--workers 3 \

--bind unix:/run/gunicorn.sock \

djangoapp1.wsgi:application

[Install]

WantedBy=multi-user.target

ngnix conf file :

server {

listen 80;

listen 443;

server_name **.***.***.*;

location = /favicon.ico { access_log off; log_not_found off; }

location /static/ {

root /home/ubuntu/djangoapp1;

}

location /media/ {

root /home/ubuntu/djangoapp1;    

}

location / {

include proxy_params;

proxy_pass http://unix:/run/gunicorn.sock;

}

}

I check the gunicorn socket with :

sudo systemctl start gunicorn.socket

sudo systemctl enable gunicorn.socket

sudo systemctl status gunicorn.socket

and it shows it running fine

I've also created a nginx conf file :

sudo vim /etc/nginx/sites-available/djangoapp1

and linked it with :

sudo ln -s /etc/nginx/sites-available/djangoapp1 /etc/nginx/sites-enabled

then restarted the nginx server:

sudo systemctl restart nginx

Still, nothing works! would appreciate any help.

Apr 4 in Others by Kichu
• 15,450 points
62 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

How to create subnet inside a VPC in AWS using Terraform?

Hi@akhtar, You need to use aws_subnet resource inside your ...READ MORE

answered Jul 21, 2020 in Others by MD
• 95,340 points
147 views
0 votes
1 answer

How to create a App using Material Design?

Hi@akhtar, You need to use the MaterialApp method ...READ MORE

answered Jul 23, 2020 in Others by MD
• 95,340 points
142 views
0 votes
1 answer

How to deploy card banners in flutter app?

Hi, If you are trying to create a ...READ MORE

answered Sep 2, 2020 in Others by MD
• 95,340 points
582 views
0 votes
0 answers

how can I deploy a test in pytest framework to airflow using DAG?

I have established an automative testing framework ...READ MORE

Oct 4, 2021 in Others by Yuan
• 120 points
24 views
0 votes
1 answer

Avoid killing children when parent process is killed

I would recommend against your design as ...READ MORE

answered Sep 7, 2018 in Python by Priyaj
• 58,060 points
3,389 views
0 votes
1 answer

Avoid killing children when parent process is killed

I would recommend against your design as ...READ MORE

answered Sep 14, 2018 in Python by Priyaj
• 58,060 points
173 views
+1 vote
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP