I have a .Net application that I am trying to deploy on Fargate.
At the moment the healthcheck from the public DNS is passing but the healthcheck from the individual privateIps of the registered targets is failing. See picture below
Is there anything I need to configure in my code or Program.cs to allow these requests through? This is what my Program.cs looks like at the moment
using CHIPADMINWEB.Extensions;
using Microsoft.AspNetCore.Mvc;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks();
builder.RegisterServices(typeof(Program));
var isLocalEnv = Environment.GetEnvironmentVariable("IS_LOCAL_ENV");
if (string.IsNullOrEmpty(isLocalEnv) || !isLocalEnv.ToLower().Equals("true"))
{
builder.Services.AddDataProtection().PersistKeysToAWSSystemsManager("/Backoffice/Frontend/DataProtection");
builder.Services.AddMvc();
}
var app = builder.Build();
app.MapHealthChecks("/healthz.html").AllowAnonymous();
app.RegisterPipelineComponents(typeof(Program));
Console.WriteLine($"Urls from Program.cs before app.Run(): {string.Join(", ", app.Urls)}");
app.Run("http://*:80");
Console.WriteLine($"Urls from Program.cs afte app.Run(): {string.Join(", ", app.Urls)}");
Any help would be greatly appreciated.
Below, please find the output of the following commands.
aws elbv2 describe-target-groups
{
"TargetGroups": [
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:533267186874:targetgroup/TestSt-testb-R7CTTOEHJ3YZ/edc6b4640fe04145",
"TargetGroupName": "TestSt-testb-R7CTTOEHJ3YZ",
"Protocol": "HTTP",
"Port": 80,
"VpcId": "vpc-0daab6dbe1f80c361",
"HealthCheckProtocol": "HTTP",
"HealthCheckPort": "traffic-port",
"HealthCheckEnabled": true,
"HealthCheckIntervalSeconds": 30,
"HealthCheckTimeoutSeconds": 10,
"HealthyThresholdCount": 5,
"UnhealthyThresholdCount": 2,
"HealthCheckPath": "/healthz.html",
"Matcher": {
"HttpCode": "200"
},
"LoadBalancerArns": [
"arn:aws:elasticloadbalancing:us-east-1:533267186874:loadbalancer/app/test-backofficebackend-lb/faa19d4b7637ee2b"
],
"TargetType": "ip",
"ProtocolVersion": "HTTP1",
"IpAddressType": "ipv4"
},
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:533267186874:targetgroup/TestSt-testb-YBCCMPDKJYVP/ee7f7b52f9d4fce5",
"TargetGroupName": "TestSt-testb-YBCCMPDKJYVP",
"Protocol": "HTTP",
"Port": 80,
"VpcId": "vpc-0daab6dbe1f80c361",
"HealthCheckProtocol": "HTTP",
"HealthCheckPort": "traffic-port",
"HealthCheckEnabled": true,
"HealthCheckIntervalSeconds": 30,
"HealthCheckTimeoutSeconds": 10,
"HealthyThresholdCount": 5,
"UnhealthyThresholdCount": 2,
"HealthCheckPath": "/healthz.html",
"Matcher": {
"HttpCode": "200"
},
"LoadBalancerArns": [
"arn:aws:elasticloadbalancing:us-east-1:533267186874:loadbalancer/app/test-backofficefrontend-lb/6721d13b8aad4bd1"
],
"TargetType": "ip",
"ProtocolVersion": "HTTP1",
"IpAddressType": "ipv4"
},
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:533267186874:targetgroup/TestSt-testm-W2PLGYCYO3NA/84e37f2be9769802",
"TargetGroupName": "TestSt-testm-W2PLGYCYO3NA",
"Protocol": "HTTP",
"Port": 80,
"VpcId": "vpc-0daab6dbe1f80c361",
"HealthCheckProtocol": "HTTP",
"HealthCheckPort": "traffic-port",
"HealthCheckEnabled": true,
"HealthCheckIntervalSeconds": 30,
"HealthCheckTimeoutSeconds": 10,
"HealthyThresholdCount": 5,
"UnhealthyThresholdCount": 2,
"HealthCheckPath": "/healthz.html",
"Matcher": {
"HttpCode": "200"
},
"LoadBalancerArns": [
"arn:aws:elasticloadbalancing:us-east-1:533267186874:loadbalancer/app/test-mobileappbackend-lb/c85648b4e24646b4"
],
"TargetType": "ip",
"ProtocolVersion": "HTTP1",
"IpAddressType": "ipv4"
}
]
}
aws elbv2 describe-target-health --target-group-arn arn:aws:elasticloadbalancing:us-east-1:533267186874:targetgroup/TestSt-testb-YBCCMPDKJYVP/ee7f7b52f9d4fce5
{
"TargetHealthDescriptions": [
{
"Target": {
"Id": "10.0.3.229",
"Port": 80,
"AvailabilityZone": "us-east-1b"
},
"HealthCheckPort": "80",
"TargetHealth": {
"State": "draining",
"Reason": "Target.DeregistrationInProgress",
"Description": "Target deregistration is in progress"
}
},
{
"Target": {
"Id": "10.0.3.50",
"Port": 80,
"AvailabilityZone": "us-east-1b"
},
"HealthCheckPort": "80",
"TargetHealth": {
"State": "draining",
"Reason": "Target.DeregistrationInProgress",
"Description": "Target deregistration is in progress"
}
}
]
}
Turns out there was logic in the middlewarecode to determine the browser that was being used. There was an exception handler that was not loggin any messages. The code that was checking the browser type was complaing and throwing a 500 status code with no logging. Once I figured this out, the issue was easy to fix in that I ignore the middleware code for the health endpoint