Search code examples
amazon-web-servicesamazon-elastic-beanstalkamazon-cloudfront

Cloudfront - elastic beanstalk(single instance) - 403 or 500 in some api calls


Setup:

  1. spring boot backend running perfectly on an elastic beanstalk single instance environment(no load balancer, http).
  2. cloud front distribution with origin as the elastic beanstalk link, origin protocol http only, behaviour settings: behaviour config

alternate domain added with a valid certificate.

Problem: I am able to make the a login post request with the correct answer. Post that the other requests return 500 - "x-cache": "Error from cloudfront" or 403 - "x-cache": "Error from cloudfront".

Stuck here for 2 days, any help will be appreciated. Thanks

Edit: Invalidated cache > used cloudfront url from swagger to check apis > all works gr8 > used custom url > only login works > use cloud front url again > only login works, requests with auth header don't.


Solution

  • I would suggest you should use application load balancer from AWS and ensure min and max instances to be same as 1. But ideally while deploying any web app, you should use more than single instances from availibility purposes.