diff --git a/proxy/http_proxy.go b/proxy/http_proxy.go index c8226a3a5..28ef2feff 100644 --- a/proxy/http_proxy.go +++ b/proxy/http_proxy.go @@ -150,6 +150,11 @@ func (p *HTTPProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { // TODO(fs): a defensive approach. if t.StripPath != "" && strings.HasPrefix(r.URL.Path, t.StripPath) { targetURL.Path = targetURL.Path[len(t.StripPath):] + // ensure absolute path after stripping to maintain compliance with + // section 5.1.2 of RFC2616 (https://tools.ietf.org/html/rfc2616#section-5.1.2) + if !strings.HasPrefix(targetURL.Path, "/") { + targetURL.Path = "/" + targetURL.Path + } } if err := addHeaders(r, p.Config, t.StripPath); err != nil {