diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index 05cc299..8a182dd 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -247,6 +247,8 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Auth-Request-Redirect $request_uri; + # or, if you are handling multiple domains: + # proxy_set_header X-Auth-Request-Redirect $scheme://$host$request_uri; } location = /oauth2/auth { proxy_pass http://127.0.0.1:4180; diff --git a/oauthproxy.go b/oauthproxy.go index 2418e73..5af2e9c 100644 --- a/oauthproxy.go +++ b/oauthproxy.go @@ -480,7 +480,10 @@ func (p *OAuthProxy) GetRedirect(req *http.Request) (redirect string, err error) return } - redirect = req.Form.Get("rd") + redirect = req.Header.Get("X-Auth-Request-Redirect") + if req.Form.Get("rd") != "" { + redirect = req.Form.Get("rd") + } if !p.IsValidRedirect(redirect) { redirect = req.URL.Path if strings.HasPrefix(redirect, p.ProxyPrefix) {