这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/bosun/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func main() {
w.WriteHeader(204)
return
}
r.Host = c.TSDBHost
rp.ServeHTTP(w, r)
}))
slog.Infoln("readonly relay at", ts.URL, "to", tsdbHost)
Expand Down
13 changes: 9 additions & 4 deletions cmd/bosun/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func Listen(listenAddr string, devMode bool, tsdbHost string) error {

type relayProxy struct {
*httputil.ReverseProxy
host string
}

type passthru struct {
Expand Down Expand Up @@ -153,6 +154,7 @@ func (rp *relayProxy) ServeHTTP(responseWriter http.ResponseWriter, r *http.Requ
}
reader := &passthru{ReadCloser: r.Body}
r.Body = reader
r.Host = rp.host
w := &relayWriter{ResponseWriter: responseWriter}
rp.ReverseProxy.ServeHTTP(w, r)
indexTSDB(r, reader.buf.Bytes())
Expand All @@ -163,10 +165,13 @@ func (rp *relayProxy) ServeHTTP(responseWriter http.ResponseWriter, r *http.Requ
}

func Relay(dest string) http.Handler {
return &relayProxy{ReverseProxy: httputil.NewSingleHostReverseProxy(&url.URL{
Scheme: "http",
Host: dest,
})}
return &relayProxy{
ReverseProxy: httputil.NewSingleHostReverseProxy(&url.URL{
Scheme: "http",
Host: dest,
}),
host: dest,
}
}

func indexTSDB(r *http.Request, body []byte) {
Expand Down