- Newest
- Most votes
- Most comments
Hello.
A 504 error in CloudFront indicates that access from CloudFront to the origin (EC2 in this case) has failed.
For example, what protocol did you choose when setting up the origin in CloudFront?
If you choose HTTPS, you need to enable HTTPS communication on EC2 and configure the web server to listen for HTTPS.
Please check the following document for troubleshooting instructions.
https://repost.aws/knowledge-center/cloudfront-troubleshoot-504-errors
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-504-gateway-timeout.html
Hey Riku, thanks a lot. Make sense your reply, I try it and let you know...
Yes, an SSL certificate is required to communicate over HTTPS.
However, since the domain "amazonaws.com" is managed by AWS, a certificate cannot be issued using Let's Encrypt, etc.
I think you need to buy your own domain and set up a certificate or create a self-cert.
It doesn't work, I think I did everything, the problem is with the HTTPS for ec2 Public IPv4 DNS, it's broken I put the firewall in the PHP server for both ports, and put the security groups for HTTPS, but I can't access the HTTPS for the ec2
Maybe, do I have to set the certificate to the ec2 DNS as well?
works: http://ec2-18-234-142-54.compute-1.amazonaws.com/ doesn't work: https://ec2-18-234-142-54.compute-1.amazonaws.com/

Thanks for your reply, I have fixed the issue, from de distribution CloudFront redirects only the HTTP traffic to HTTPS domain, and works!