简体   繁体   中英

api request 403 error from aws s3 cloudfront to ec2

I distributed spring boot to aws ec2 and vue.js to s3 cloudfront.

Request for ec2 in my locality is performed normally performed. However, requesting ec2 on cloudfront results in 403 access denied on the web without a server response.

It is being requested through vue.js proxy, and all settings such as security policies have been completed.

What is the problem?

There could be multiple issues with it. Follow the steps below to debug it

  • Ensure that your APIs are working without CloudFront. Try to access the APIs hosted on EC2 instance. (you have to open them up for public before using them from CloudFront so ensure that ports are open, etc.)

  • Check the cache settings. For APIs path (behaviour) it should be no-cache

  • Make sure the behaviours are setup correctly in the CloudFormation. Behaviours configuration set the path / routes of incoming requests and map them to origins

  • Enable logging for CloudFront and analyse that

CloudFront doesn't translate the error messages exactly for security reasons. If an object or path doesn't exists CF will show 403 rather than 404. This is to prevent exploits to identify which HTTP resource exists and which not. Update your question with the findings which will help others to share the solutions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM