WisdomSky / Cloudflared-web

Cloudflared-web is a docker image that packages both cloudflared cli and a simple Web UI to easily start or stop remotely-managed Cloudflare tunnel.
118 stars 14 forks source link

a better way to implement healthcheck? #8

Closed captmicr0 closed 4 months ago

captmicr0 commented 4 months ago

Currently adding healthchecks to all my docker containers, and this container specifically was quite hard to implement one for.

I wanted the healthcheck to be based on the status of the tunnel connection, giving a healthy status when the tunnel is connected.

Right now I'm using this in my docker-compose file:

healthcheck:
      test: "curl -s -L http://localhost:14333/config | node -e 'process.exit((JSON.parse(require(\"fs\").readFileSync(0).toString()).start)==\"false\")'"
      interval: 30s
      timeout: 10s
      retries: 5

Any plans to implement a healthcheck in the Dockerfile itself?

WisdomSky commented 4 months ago

I'm not sure if we'll gonna add a dedicated healthcheck that's tied to the tunnel's status as it's not really that important since you can always refer to the health status of the tunnel directly from your zerotrust dashboard.

Also the healthcheck should supposedly refer to the container's status rather than the tunnel's. If we tie the healthcheck to the tunnel connection, docker will think that the container is unhealthy if you stopped the tunnel even though the container is running perfectly fine. So it will create a confusion right there.


For your use-case, you might want to use Cloudflare API and use that for adding a custom healthcheck for the container:

https://developers.cloudflare.com/api/operations/cloudflare-tunnel-get-a-cloudflare-tunnel

The response object contains a status property that tells you if the connection is healthy or not. This is more accurate and reliable than checking if the start value in the config is true/false.

WisdomSky commented 4 months ago

Closing this issue.