2021-07-29

Can't communicate with API hosting on AWS EC2 via https

Problem: I can send an HTTP request to my website hosted on an EC2 instance via the auto-generated IPv4 DNS (ec2-12-345-67-899.compute-1.amazonaws.com) and receive a correct response, but when I try to send an HTTPS request, the page keeps loading and I eventually got "ec2-12-345-67-899.compute-1.amazonaws.com took too long to respond"

Details:

  • I am using Flask, Gunicorn as the webserver, and Nginx as the reverse proxy server
  • Here is my Nginx configuration file:
server {
    listen 443;
    listen 80;
    server_name ec2-12-345-67-899.compute-1.amazonaws.com;

    location / {
        proxy_pass http://localhost:5000;
    }
}
  • Here is what it looks like when I start my gunicorn server: gunicorn running

  • Here is my EC2's instance Sercurity Group:

ec2 security group

Notes: I'm a beginner so I don't know if the above information is enough. Please let me know if there's other information I need to provide.

I thought the DNS provided by the EC2 instance should be SSL-certified? If it's not then do I need to get an SSL certification and put the link to it in my Nginx Configuration file?

I tried to use Let's Encrypt but it said it cannot provide a certificate for the requested domain name (probably because the domain name belongs to Amazon).

My ultimate goal is to be able to communicate with my website hosted on EC2 instance via HTTPS. Is buying a domain name the only way?



from Recent Questions - Stack Overflow https://ift.tt/3rDAlj0
https://ift.tt/3BQ8LUm

No comments:

Post a Comment