Bala krishna
Bala krishna

Reputation: 639

AWS ALB health check failure

I have created an AWS EC2 instance and running a jenkins container inside it, Here are the details :

CONTAINER ID  IMAGE                      COMMAND  CREATED       STATUS           PORTS                                             NAMES
xxxxxxxxx  docker.io/jenkins/jenkins           47 hours ago  Up 47 hours ago  0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp  jenkins

after that I have configured an AWS ALB to listen on port 443 and given this jenkins instance running jenkins container as target.

The loadbalancer health check details are as below: enter image description here

I have tried with traffic port aswell, but that also showd unhealthy.

after this my loadbalancer is able to forward request to the instance and I am able to reach jenkins container with the loadbalancer dns.

But my Loadbalancer is showing my target as unhealthy, enter image description here

Can some one help me why my target is not healthy and what steps i could do to make it healthy.

Upvotes: 1

Views: 4151

Answers (3)

Afnan Qureshi
Afnan Qureshi

Reputation: 11

I created a Jenkins container on Fargate ECS and it was giving me this error when I tried to configure an ALB to it. service jenkins-alb (port 8080) is unhealthy in target-group ecs-demo2-jenkins-alb due to (reason Health checks failed with these codes: [403]).

I found the solution that when the ALB healthcheck tries to go to the target group, it is greeted with the jenkins login page and requires authorization which is why the healthcheck fails with error 403. The workaround I used for this was to change the healthcheck path from '/' to '/login?from=%2F' and it worked!

Upvotes: 1

Arijit Ghosh
Arijit Ghosh

Reputation: 151

Use /login instead of / Verify the port no also. I am using 8080

Upvotes: 0

Asri Badlah
Asri Badlah

Reputation: 2123

Jenkins EC2 should be assigned a security group that allows access on the Jenkins port (8080) from the ALB. and you’ll provide full outbound internet access to Jenkins in order that updates and plugins can be installed.

The Jenkins requires authentication, so when the ALB is doing its health check as an anonymous user it gets a 403 access forbidden page, but http health check expect 200 ok code, so You can switch this to a tcp health check.

Upvotes: 1

Related Questions