mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
app/vmselect: follow-up after 8639e79d38
This commit is contained in:
parent
2213eef6b7
commit
3fee369997
1 changed files with 9 additions and 22 deletions
|
@ -9,7 +9,6 @@ import (
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -703,10 +702,14 @@ func mayProxyVMAlertRequests(w http.ResponseWriter, r *http.Request, path, stubR
|
||||||
panic(err)
|
panic(err)
|
||||||
}()
|
}()
|
||||||
r.URL.Path = strings.TrimPrefix(path, "prometheus")
|
r.URL.Path = strings.TrimPrefix(path, "prometheus")
|
||||||
vmalertReverseProxy.ServeHTTP(w, r)
|
r.Host = vmalertProxyHost
|
||||||
|
vmalertProxy.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
var vmalertReverseProxy *httputil.ReverseProxy
|
var (
|
||||||
|
vmalertProxyHost string
|
||||||
|
vmalertProxy *httputil.ReverseProxy
|
||||||
|
)
|
||||||
|
|
||||||
// initVMAlertProxy must be called after flag.Parse(), since it uses command-line flags.
|
// initVMAlertProxy must be called after flag.Parse(), since it uses command-line flags.
|
||||||
func initVMAlertProxy() {
|
func initVMAlertProxy() {
|
||||||
|
@ -715,24 +718,8 @@ func initVMAlertProxy() {
|
||||||
}
|
}
|
||||||
proxyURL, err := url.Parse(*vmalertProxyURL)
|
proxyURL, err := url.Parse(*vmalertProxyURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatalf("cannot parse vmalertProxyURL=%q : %s", *vmalertProxyURL, err)
|
logger.Fatalf("cannot parse -vmalert.proxyURL=%q: %s", *vmalertProxyURL, err)
|
||||||
}
|
|
||||||
vmalertReverseProxy = &httputil.ReverseProxy{
|
|
||||||
Director: func(r *http.Request) {
|
|
||||||
proxyURLCopy := *proxyURL
|
|
||||||
proxyURLCopy.Path = path.Join(proxyURL.Path, r.URL.Path)
|
|
||||||
r.URL = &proxyURLCopy
|
|
||||||
r.Host = proxyURLCopy.Host
|
|
||||||
},
|
|
||||||
Transport: func() *http.Transport {
|
|
||||||
tr := http.DefaultTransport.(*http.Transport).Clone()
|
|
||||||
// Automatic compression must be disabled in order to fix https://github.com/VictoriaMetrics/VictoriaMetrics/issues/535
|
|
||||||
tr.DisableCompression = true
|
|
||||||
// Disable HTTP/2.0, since VictoriaMetrics components don't support HTTP/2.0 (because there is no sense in this).
|
|
||||||
tr.ForceAttemptHTTP2 = false
|
|
||||||
return tr
|
|
||||||
}(),
|
|
||||||
FlushInterval: time.Second,
|
|
||||||
ErrorLog: logger.StdErrorLogger(),
|
|
||||||
}
|
}
|
||||||
|
vmalertProxyHost = proxyURL.Host
|
||||||
|
vmalertProxy = httputil.NewSingleHostReverseProxy(proxyURL)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue