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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则