Nginx – AWS ELB health check when using nginx and TCP

amazon-elbhealthchecknginx

I have an elasticbeanstalk environment that uses nginx as a frontend server for a node.js application.

The environment uses an elastic load balancer configured to accept connections on TCP:80/SSL:443 and forward both to the nginx instance on TCP:8080. I'm using TCP/SSL+ProxyProtocol, instead of HTTP/HTTPS, to support websockets.

AWS ELB does not let me use a URL for health checks from the load balancer when using TCP. I need to use one, otherwise it only checks if nginx is listening on 8080, and not if my node.js app is running.

I'm looking for ideas to make it work. The goal is to GET my node.js app health check URL, and make AWS ELB mark the instance as unhealthy if the health check URL status is not 200.

My current idea is to try to ride on nginx's support for health checks so it goes against nodejs, and if it detects the app as unhealthy stop listening to connections on 8080 so the ELB will mark the instance as unhealthy. Maybe running a command when nginx detects healthy/unhealthy instances would be enough.

Is that possible? Any other ideas?

Best Answer

Load balancer health check configuration is independent of listener endpoint configuration, so you can configure the load balancer health check with a HTTP:8080/index.html without problems.

Not sure what I was thinking...