404 can't access to alb and ec2 via croudfront

0

404 Can't access ALB and EC2 via CloudFront

I'm creating a multi-behavior CloudFront configuration, one for an S3 bucket website and the other for an EC2 application connected via an ALB. I can access the ALB using its DNS and the S3 bucket via CloudFront, but I can't access the ALB and EC2 application through CloudFront. I've carefully checked the security group ports, access permissions, and HTTP methods. I've disabled caching for both behaviors.

Enter image description here It seems that there is an issue with the connection between the Application Load Balancer (ALB) or Virtual Private Cloud (VPC) and CloudFront. However, I am having difficulty identifying the root cause of the problem. Could you please suggest possible causes for this issue?

responce is like this

404 Not Found

  • Code: NoSuchKey
  • Message: The specified key does not exist.
  • Key: efforsition

My CloudFront origin settings and behaviors are as follows: behavior table

alb origin

alb origin

1 Answer
2

Both the error "Code: NoSuchKey" and message "Message: The specified key does not exist." appear to be S3 related errors, and not ALB/EC2 related. I believe your CloudFront is only directing to S3, and you are formulating URLs that you expect to find content on your ALB/EC2 that are actually being directed to S3. When the specific item being requested does not exist in S3, particularly if there is not a bucket or folder called "efforsition", you would get the error as described.

Can you separate the S3 access and ALB/EC2 into two separate CloudFront instances? If not, revisit to ensure that your logic on funneling traffic to one or the other is correct.

profile pictureAWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions