fix: 修复 TLS ConnectionState、SPA 回退、健康检查与监听小问题
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@@ -25,8 +26,16 @@ func cmdHealthcheck(_ []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
url := "http://" + addr + "/healthz"
|
||||
scheme := "http"
|
||||
client := &http.Client{Timeout: 3 * time.Second}
|
||||
if strings.TrimSpace(cfg.TLS.CertFile) != "" && !cfg.TLS.AllowPlaintext {
|
||||
scheme = "https"
|
||||
// 只连 127.0.0.1 做存活探测,不涉及证书身份校验。
|
||||
client.Transport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec
|
||||
}
|
||||
}
|
||||
url := scheme + "://" + addr + "/healthz"
|
||||
resp, err := client.Get(url)
|
||||
if err != nil {
|
||||
return fmt.Errorf("healthcheck %s: %w", url, err)
|
||||
|
||||
Reference in New Issue
Block a user