amazon-web-serviceselasticsearchaws-alb

Adding x-pack enabled Elasticsearch behind AWS application load balancer causing health check failure due to missing authentication


I was using Application load balancer(ALB) on my elasticsearch node and configured the health check as shown in image and health check was working fine and I was able to reach to my ES using load balancer.

enter image description here

Now I added x-pack security which requires even for health check to pass a user(Elastic super user and its password) in my case and after that health check stopped working as ALB can't pass the basic authentication and due to this issue Health check is not working and as shown in image ALB is continuously de-registering the Elasticsearch which in turn causing my Elasticsearch docker to stop/start.

Note:- I am using ES 7.7 if its relevant to this question.

enter image description here


Solution

  • Based on the comments, the problem is caused by the fact that ALB health checks fail since failed authentication returns 401 HTTP code, not 200.

    The solution is to use 401 code as the expected code for the health check. The failure of authentication still means that the ES is up and running, not that it ES failed.