providers/proxy: improve error handling for invalid backend_override

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-02-07 19:59:06 +01:00
parent 20c284a188
commit e758995458

View file

@ -74,16 +74,16 @@ func (a *Application) configureProxy() error {
func (a *Application) proxyModifyRequest(ou *url.URL) func(req *http.Request) { func (a *Application) proxyModifyRequest(ou *url.URL) func(req *http.Request) {
return func(r *http.Request) { return func(r *http.Request) {
claims, _ := a.getClaims(r) claims, _ := a.getClaims(r)
r.URL.Scheme = ou.Scheme
r.URL.Host = ou.Host
if claims.Proxy != nil && claims.Proxy.BackendOverride != "" { if claims.Proxy != nil && claims.Proxy.BackendOverride != "" {
u, err := url.Parse(claims.Proxy.BackendOverride) u, err := url.Parse(claims.Proxy.BackendOverride)
if err != nil { if err != nil {
a.log.WithField("backend_override", claims.Proxy.BackendOverride).WithError(err).Warning("failed parse user backend override") a.log.WithField("backend_override", claims.Proxy.BackendOverride).WithError(err).Warning("failed parse user backend override")
return
} }
r.URL.Scheme = u.Scheme r.URL.Scheme = u.Scheme
r.URL.Host = u.Host r.URL.Host = u.Host
} else {
r.URL.Scheme = ou.Scheme
r.URL.Host = ou.Host
} }
} }
} }