Health check port/path question

I am trying to implement health checks, but I’m not sure what port/path to use. I have a stack that runs a Node/Express server on port 3000. I also have an API that is running Nginx+PHP FPM sidekick. Nginx listens on port 80 and PHP is on 9000. I have a Rancher load balancer that does SSL termination for these services. The load balancer listens on port 443 for and forwards it to the Node server on port 3000. It also listens on port 443 for and forwards to the Nginx server on port 80.

I’d like to setup health checks for each of these services, but I’m not sure what to use for the config. For the Node server health check, do I use port 3000, since that is what the Node service exposes? Or do I use port 443 because the load balancer is in front of the Node server listening on that port? Same question for my Nginx/PHP service. Do I use port 80 there since that’s where Nginx listens or port 443, since the load balancer accepts traffic there and forwards to port 80?

Also, if the Node server health check should be on port 3000 and the Nginx should be on 80, how do I handle health checks on the PHP FPM server (port 9000)? Since Nginx is in front of PHP, what would I use for health checks there?

Any advice would be appreciated. Thanks!

Health checks go directly to the target containers, so you want the ports the containers are listening on/the balancer directs traffic to, not the ones the balancer exposes. (Balancers have their own automatic health checks).

Each service can only have a single check, so if you have multiple this to check make one endpoint that tests multiple things. E.g. hitting a php page and getting back a response through nginx tells you both are working.

@vincent, I appreciate the quick reply, thanks!

One follow up questing in regards to nginx/php… The nginx service is setup with php as a sidekick. You mentioned that checking a single endpoint (i.e. hitting a php page through nginx) would determine the health of both. However, if I setup that health check on my nginx service, it will only restart the nginx containers upon failure. Is there a way to have it restart the php containers upon failure in addition to nginx, since the cause of the failure could be php instead of nginx? Or is there a separate health check I should run on the php service even though it’s setup as a sidekick to nginx?