502 errors while accessing CloudFront distribution that's connected to a load balancer

1

I have configured a CloudFront distribution to point to an application load balancer (ALB). The ALB points to a lambda function. I have configured an A record in Route53 to point to the CloudFront distribution. Hitting the ALB directly via its generated domain name, works (ie. the lambda is hit and runs and returns OK). Attempting to hit the application via the domain and CloudFront returns a 502 error:

502 ERROR
The request could not be satisfied.
CloudFront wasn't able to connect to the origin. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

How can I best troubleshoot this? Are there any frequent pitfalls I might have fallen in to?

3개 답변
2

Did you check all of the possible causes listed in the docs?

Do you have VPC Flow logs enabled, and does that give any indication as to what's happening?

AWS
전문가
답변함 일 년 전
0

Other than the above check list, you should also check if ALB has any whitelist of supported domain names, in this case your distribution supported domain name For example F5 LB can allow or deny certain HOST values if not explicitly whitelisted

답변함 일 년 전
0

Besides documentation, you can refer to How do I troubleshoot a 502: "The request could not be satisfied" error from CloudFront?.

Are you accessing your ALB directly via HTTP or HTTPS? If this is HTTP only, edit your CloudFront Origin Protocol to HTTP only

You may also want to change CloudFront Behavior to CachingDisabled

AWS
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인