[PR #153] [MERGED] fix(update): use caddy built-in metrics endpoint for health check #249

Closed
opened 2025-11-22 20:33:25 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Dokploy/templates/pull/153
Author: @rexwangcc
Created: 5/25/2025
Status: Merged
Merged: 6/1/2025
Merged by: @Siumauricio

Base: mainHead: rex/feat/fix-warnings-around-caddy-health-checks


📝 Commits (2)

  • 007c94d fix: use caddy built-in metrics endpoint for health check to avoid early closed conns.
  • 1633ce2 Merge branch 'main' into rex/feat/fix-warnings-around-caddy-health-checks

📊 Changes

1 file changed (+8 additions, -1 deletions)

View changed files

📝 blueprints/rybbit/docker-compose.yml (+8 -1)

📄 Description

Why

With the current health check, we'd get tons of warning logs under the Caddy container complaining something like:

{"level":"warn","ts":1748150819.4112387,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","upstream":"rybbit_client:3002","duration":0.004111297,"request":{"remote_ip":"127.0.0.1","remote_port":"49632","client_ip":"127.0.0.1","proto":"HTTP/1.1","method":"GET","host":"rybbit_client:3002","uri":"/","headers":{"X-Real-Ip":[""],"Via":["1.1 Caddy"],"Accept":["/"],"X-Forwarded-For":["127.0.0.1"],"User-Agent":["Wget"],"X-Forwarded-Proto":["http"],"X-Forwarded-Host":["127.0.0.1:80"]}},"error":"writing: write tcp 127.0.0.1:80->127.0.0.1:48632: write: broken pipe"}

it is because for the current health check ["CMD", "wget", "--spider", "--quiet", "http://127.0.0.1:80"], the --spider flag tells wget to not download the response body - it just checks if the URL exists and then immediately closes the connection; however, Rybbit Next app is trying to send the full response, but wget has already closed the connection, causing the "broken pipe" error.

How

  • Ideally we would use curl to perform the health checks, but caddy image does not come with it
  • Looking at caddy_clickhouse, and docker compose's conventions, apparently we want to scope the health checks to its own service rather than let it cascade, so I changed the health check to only probe caddy's built-in /metrics endpoint
  • using --no-verbose over --quiet for logging purposes, former does not suppress errors.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Dokploy/templates/pull/153 **Author:** [@rexwangcc](https://github.com/rexwangcc) **Created:** 5/25/2025 **Status:** ✅ Merged **Merged:** 6/1/2025 **Merged by:** [@Siumauricio](https://github.com/Siumauricio) **Base:** `main` ← **Head:** `rex/feat/fix-warnings-around-caddy-health-checks` --- ### 📝 Commits (2) - [`007c94d`](https://github.com/Dokploy/templates/commit/007c94d8fb80f7277588a1c8bc768f1d600ae5b6) fix: use caddy built-in metrics endpoint for health check to avoid early closed conns. - [`1633ce2`](https://github.com/Dokploy/templates/commit/1633ce230580b8adfb013688905a070ddf42836d) Merge branch 'main' into rex/feat/fix-warnings-around-caddy-health-checks ### 📊 Changes **1 file changed** (+8 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `blueprints/rybbit/docker-compose.yml` (+8 -1) </details> ### 📄 Description ## Why With the current health check, we'd get tons of warning logs under the `Caddy` container complaining something like: ```json {"level":"warn","ts":1748150819.4112387,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","upstream":"rybbit_client:3002","duration":0.004111297,"request":{"remote_ip":"127.0.0.1","remote_port":"49632","client_ip":"127.0.0.1","proto":"HTTP/1.1","method":"GET","host":"rybbit_client:3002","uri":"/","headers":{"X-Real-Ip":[""],"Via":["1.1 Caddy"],"Accept":["/"],"X-Forwarded-For":["127.0.0.1"],"User-Agent":["Wget"],"X-Forwarded-Proto":["http"],"X-Forwarded-Host":["127.0.0.1:80"]}},"error":"writing: write tcp 127.0.0.1:80->127.0.0.1:48632: write: broken pipe"} ``` it is because for the current health check `["CMD", "wget", "--spider", "--quiet", "http://127.0.0.1:80"]`, the `--spider` flag tells wget to not download the response body - it just checks if the URL exists and then immediately closes the connection; however, `Rybbit` Next app is trying to send the full response, but wget has already closed the connection, causing the "broken pipe" error. ## How - Ideally we would use `curl` to perform the health checks, but `caddy` image does not come with it - Looking at `caddy_clickhouse`, and docker compose's conventions, apparently we want to scope the health checks to its own service rather than let it cascade, so I changed the health check to only probe `caddy`'s built-in `/metrics` endpoint - using `--no-verbose` over `--quiet` for logging purposes, former does not suppress errors. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-22 20:33:25 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/templates#249