From bb7d51b0db3734908d01de6d8428ba920d741aaf Mon Sep 17 00:00:00 2001 From: Kaive Young Date: Wed, 20 Mar 2024 10:45:36 +0800 Subject: [PATCH] add header for http health check --- client/health/health.go | 4 +--- conf/frpc_full_example.toml | 1 - pkg/config/v1/proxy.go | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/client/health/health.go b/client/health/health.go index bc08540a..34c85da5 100644 --- a/client/health/health.go +++ b/client/health/health.go @@ -42,7 +42,6 @@ type Monitor struct { // For http url string header http.Header - host string failedTimes uint64 statusOK bool statusNormalFn func() @@ -87,7 +86,6 @@ func NewMonitor(ctx context.Context, cfg v1.HealthCheckConfig, addr string, addr: addr, url: url, header: header, - host: cfg.HostHeaderRewrite, statusOK: false, statusNormalFn: statusNormalFn, statusFailedFn: statusFailedFn, @@ -172,7 +170,7 @@ func (monitor *Monitor) doHTTPCheck(ctx context.Context) error { return err } req.Header = monitor.header - req.Host = monitor.host + req.Host = monitor.header.Get("Host") resp, err := http.DefaultClient.Do(req) if err != nil { return err diff --git a/conf/frpc_full_example.toml b/conf/frpc_full_example.toml index 42f77c8c..1e4c9a53 100644 --- a/conf/frpc_full_example.toml +++ b/conf/frpc_full_example.toml @@ -220,7 +220,6 @@ healthCheck.timeoutSeconds = 3 healthCheck.headers=[ { name = "x-from-where", value = "frp" } ] -healthCheck.hostHeaderRewrite = "example.com" [[proxies]] name = "web02" diff --git a/pkg/config/v1/proxy.go b/pkg/config/v1/proxy.go index c17dd6fd..f45c001a 100644 --- a/pkg/config/v1/proxy.go +++ b/pkg/config/v1/proxy.go @@ -100,9 +100,6 @@ type HealthCheckConfig struct { // Headers specifies the headers to send health checks to if the // health check type is "http". Headers []HTTPHeader `json:"headers,omitempty"` - // HostHeaderRewrite specifies the request host to send health checks to if the - // health check type is "http". - HostHeaderRewrite string `json:"hostHeaderRewrite,omitempty"` } type DomainConfig struct {