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.