Daniel Leach
Daniel Leach

Reputation: 7355

Why does an AWS ALB configured for a AspNetCore Lambda function give a 502 after when redirected?

I have project setup based on the AspNetCoreWebApp template from aws-lambda-dotnet.

The lambda entry point is setup the same as the template.

I can see an unsecured page fine, but when attempting to go to a secured page, I get a 502 Status Code response from the load balancer.

Based on aws troubleshooting:

The target response is malformed or contains HTTP headers that are not valid.

The lambda function redirects work fine fine with API Gateway in front of it.

Upvotes: 2

Views: 651

Answers (1)

Daniel Leach
Daniel Leach

Reputation: 7355

Don't forget to read the Readme:

Change the base class to Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction when using an Application Load Balancer.

Although the Lambda function seems to work using the APIGatewayProxyFunction base class, the headers for Content-Type will come back as [null] during a redirect which the ALB does not appear to support. Change the base class of LambdaEntryPoint to ApplicationLoadBalancerFunction and the redirects will work correctly.

Upvotes: 2

Related Questions