alz
alz

Reputation: 347

AWS - Error 502 between CloudFront and EC2 SSL certificate - Mobile App

Given these premises, in the EC2 instance there is not a landing html page (like hello world!) to be reached if the CloudFront Distribution domain name or the domain name is pinged.

However, If I ping it, I get the 502 error (502 ERROR The request could not be satisfied. CloudFront wasn't able to connect to the origin. We can't connect to the server for this app or website at this time).

The domain was validated in the SSLlab without throwing errors except a "Chain issues Incorrect order, Extra certs" in the "Additional Certificates section" (not in the "Server Key and Certificate #1") and the X-Cache says: Error from CloudFront.

How can I fix the 502 error?

EDIT

I've posted the solution in the comment

Upvotes: 1

Views: 1482

Answers (2)

PeiSong
PeiSong

Reputation: 919

In my case, you MUST use fullchain.pem certificate instead of the shorter cert.pem one. Otherwise cloudfront will fail to load non / url if it is a single page app.

Upvotes: 0

alz
alz

Reputation: 347

The solution was to keep everything as above stated but:

  • remove the ssl certificate from the instance
  • generate a new ssl certificate in Certificate Manager from Amazon (this also implies creating records in Route 53 of the CNAME of the new certificate and selecting the new certificate in the Cloudfront distribution).

At the end the issue was a conflict between the two ssl certificates. Only one had to be kept.

Upvotes: 1

Related Questions