Skip to content

Commit

Permalink
ensure absolute path after strip to maintain rfc complaince
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Hurt committed Apr 18, 2019
1 parent 65b31ca commit cb89bf9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions proxy/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit cb89bf9

Please sign in to comment.