How to fix 504 ERROR with route 53, cloudfront distribution and elastic beanstalk
CloudFront serves 504 only if it couldn't either establish TCP connection or the HTTP first byte response took more then what was configured in Origin read/response timeout.
Does your application work directly with beanstalk link or do you have any security group restriction based on IP ?
James
Updated on June 07, 2022Comments
-
James almost 2 years
I'm not able to get my nodejs api working using elastic beanstalk, cloudfront distribution and route 53. I need my api to be running behind an SSL, this is why I'm using cloudfront distribution. I have the following setup.
When I visit my api
https://api.mydomain.com
I get a 504 with the error message below.The actual url my api is running on (successfully, using nodejs elastic with beanstalk) is
http://dummy-env.n1eijsdai.eu-west-1.elasticbeanstalk.com
. I just want to mask that url asapi.mydomain.com
together with an SSL.Is there something I've got wrong/ can you suggest anything to try?
Looking through the configuration for cloudfront this looks strange, the picture shows the setting prefixed with S3 but this api is not on an S3 (at least directly) it is hosted by elastic beanstalk.
Thanks,
Error message
504 ERROR The request could not be satisfied. CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection. If you received this error while trying to use an app or access a website, please contact the provider or website owner for assistance.
Route 53
- name = api.mydomain.com
- Type = (A) Alias target = wqsdn31817
CloudFront Distributions
domain name = wqsdn31817
origin = dummy-env.n1eijsdai.eu-west-1.elasticbeanstalk.com (if I visit this url I see my api running)
SSL certificate = api.mydomain.com
status = deployed
Origin Settings/ Origin Domain Name = http://dummy-env.n1eijsdai.eu-west-1.elasticbeanstalk.com
Origin Settings/ Origin Protocol Policy = HTTPS Only
Elastic Beanstalk
Nodejs api (using express)
In beanstalk Environment ID: e-1nasn4, URL: dummy-env.n1eijsdai.eu-west-1.elasticbeanstalk.com
-
James almost 5 yearsWhen I browse the url that beanstalk provides after deploying it my nodejs api is running on http
-
James Dean almost 5 yearsOrigin Settings/ Origin Protocol Policy = HTTPS Only, you set this cloudfront, does beanstalk work directly on https as well from browser/public ?