diff --git a/main.go b/main.go index c32f53f..7e10010 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "html/template" "io" "log" + "net" "net/http" "net/http/httputil" "net/url" @@ -14,6 +15,7 @@ import ( "path/filepath" "strconv" "strings" + "time" "gopkg.in/yaml.v3" ) @@ -295,9 +297,10 @@ func adminHandler(w http.ResponseWriter, r *http.Request) { resp.Body.Close() } caddyUp := false - if resp, err := http.Get("http://127.0.0.1:80/"); err == nil { + // Check port 80 responds (don't follow HTTPS redirect) + if conn, err := net.DialTimeout("tcp", "127.0.0.1:80", 3*time.Second); err == nil { caddyUp = true - resp.Body.Close() + conn.Close() } launcherUp := false if resp, err := http.Get("http://127.0.0.1:9000/health"); err == nil {