mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-30 10:35:18 -04:00
Use authentification credentials from proxy's configuration as a default. (#951)
This commit is contained in:
committed by
Matt Holt
parent
6490ff6224
commit
62e8c4b76b
@@ -110,6 +110,12 @@ func (p Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if proxy == nil {
|
||||
proxy = NewSingleHostReverseProxy(nameURL, host.WithoutPathPrefix)
|
||||
}
|
||||
|
||||
// use upstream credentials by default
|
||||
if outreq.Header.Get("Authorization") == "" && nameURL.User != nil {
|
||||
pwd, _ := nameURL.User.Password()
|
||||
outreq.SetBasicAuth(nameURL.User.Username(), pwd)
|
||||
}
|
||||
} else {
|
||||
outreq.Host = host.Name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user