Putting AWS cloudfront in front of ec2 throws 502 error

Viewed 1506

I am trying to add SSL to my EC2 instance that hosts my API's in a node.js server by:

1) Provisioning a certificate from Certificate Manager 2) Putting Cloudfront in front of my EC2 instance 3) Adding record set in Route53

Before I actually added the record set in Route 53, I made a GET request via postman to my health check api

GET cloudfrontdistro.cloudfront.net/health

And the response was a 502 with the message

We can't connect to the server for this app or website at this time. There might be too much traffic or a
configuration error. Try again later, or contact the app or website owner.

Relevant details about my Cloudfront distro:

  • I used a Custom SSL Cert - the one that I got from ACM)
  • TLSv1.2_2018 security policy
  • Origin domain name is ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com
  • Minimum origin SSL protocol is TLSv1
  • Origin protocol policy is HTTPS Only
  • HTTP Port 80
  • HTTPS Port 443
  • Viewer Protocol Policy is Redirect HTTP to HTTPS
  • Allowed HTTP Methods are GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

Any help would greatly be appreciated! TIA!

1 Answers
Related