Skip to content

Commit

Permalink
documentation: add tail_proxy_url option to query_frontend_config sec…
Browse files Browse the repository at this point in the history
…tion (#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.
  • Loading branch information
zhanghjster authored Nov 5, 2020
1 parent 9249ebc commit bc202ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/sources/configuration/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <duration> | default = 0s]
# URL of querier for tail proxy.
# CLI flag: -frontend.tail-proxy-url
[tail_proxy_url: <string> | default = ""]
```

## queryrange_config
Expand Down
7 changes: 7 additions & 0 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc202ae

Please sign in to comment.