Skip to content

Commit

Permalink
Switched from NewSingleHostReverseProxy to directly creating ReverseP…
Browse files Browse the repository at this point in the history
…roxy
  • Loading branch information
spaparaju committed Jan 25, 2021
1 parent 7842f73 commit 29bdd08
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,20 @@ func main() {

if cfg.url != nil {
ctx, cancel := context.WithCancel(ctx)
p := httputil.NewSingleHostReverseProxy(cfg.url)
// ReverseProxy requiring explicitly set Hostname at both HttpRequest and HttpRequest.URL.
p.Director = func(req *http.Request) {
req.URL.Scheme = cfg.url.Scheme
req.Host = cfg.url.Hostname()
req.URL.Host = cfg.url.Hostname()
p := httputil.ReverseProxy{
Director: func(req *http.Request) {
req.URL.Scheme = cfg.url.Scheme
req.Host = cfg.url.Hostname()
req.URL.Host = cfg.url.Hostname()
},
}
p.Transport = &oauth2.Transport{
Source: ccc.TokenSource(ctx),
}

s := http.Server{
Addr: cfg.server.listen,
Handler: p,
Handler: &p,
}
g.Add(func() error {
level.Info(logger).Log("msg", "starting proxy server", "address", s.Addr)
Expand Down

0 comments on commit 29bdd08

Please sign in to comment.