How to fix 504 ERROR with route 53, cloudfront distribution and elastic beanstalk

Viewed 15256

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 as api.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.

cloudfront setting that mentions S3 in the value, it's in beanstalk (not S3)

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

1 Answers

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 ?

Related