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
feita há 2 meses172 visualizações
3 Respostas
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
ESPECIALISTA
Paul_L
respondido há 2 meses
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
respondido há 2 meses
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
ESPECIALISTA
Mike_L
respondido há 2 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas