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?

Nik
已提問 2 個月前檢視次數 172 次
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
專家
Paul_L
已回答 2 個月前
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

Anand
已回答 2 個月前
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
專家
Mike_L
已回答 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南