From bc202ae7eccce8d41841989378b2706e563fdb9c Mon Sep 17 00:00:00 2001 From: zhanghjster Date: Thu, 5 Nov 2020 18:06:22 +0800 Subject: [PATCH] documentation: add tail_proxy_url option to query_frontend_config section (#2879) * add tail_proxy_url option to the query_frontend_config section of configuration doc * If queryFrontend run in tail proxy mode, append the Host of the tail_proxy_url to the request header, because in some scenario queryFrontend forward tail to the queriers deployed behind nginx and "Host" is required. --- docs/sources/configuration/_index.md | 4 ++++ pkg/loki/modules.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/docs/sources/configuration/_index.md b/docs/sources/configuration/_index.md index 2d297b626f2a..04b4d2f1e38f 100644 --- a/docs/sources/configuration/_index.md +++ b/docs/sources/configuration/_index.md @@ -296,6 +296,10 @@ The query_frontend_config configures the Loki query-frontend. # Set to < 0 to enable on all queries. # CLI flag: -frontend.log-queries-longer-than [log_queries_longer_than: | default = 0s] + +# URL of querier for tail proxy. +# CLI flag: -frontend.tail-proxy-url +[tail_proxy_url: | default = ""] ``` ## queryrange_config diff --git a/pkg/loki/modules.go b/pkg/loki/modules.go index 57640983211f..0de2559c146a 100644 --- a/pkg/loki/modules.go +++ b/pkg/loki/modules.go @@ -383,6 +383,13 @@ func (t *Loki) initQueryFrontend() (_ services.Service, err error) { return nil, err } tp := httputil.NewSingleHostReverseProxy(tailURL) + + director := tp.Director + tp.Director = func(req *http.Request) { + director(req) + req.Host = tailURL.Host + } + defaultHandler = httpMiddleware.Wrap(tp) } else { defaultHandler = frontendHandler