summaryrefslogtreecommitdiffhomepage
path: root/caddyhttp/proxy/reverseproxy.go
diff options
context:
space:
mode:
Diffstat (limited to 'caddyhttp/proxy/reverseproxy.go')
-rw-r--r--caddyhttp/proxy/reverseproxy.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/caddyhttp/proxy/reverseproxy.go b/caddyhttp/proxy/reverseproxy.go
index 1374c08ff..c537f7c98 100644
--- a/caddyhttp/proxy/reverseproxy.go
+++ b/caddyhttp/proxy/reverseproxy.go
@@ -96,7 +96,13 @@ func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int) *
}
}
+ hadTrailingSlash := strings.HasSuffix(req.URL.Path, "/")
req.URL.Path = path.Join(target.Path, req.URL.Path)
+ // path.Join will strip off the last /, so put it back if it was there.
+ if hadTrailingSlash && !strings.HasSuffix(req.URL.Path, "/") {
+ req.URL.Path = req.URL.Path + "/"
+ }
+
// Trims the path of the socket from the URL path.
// This is done because req.URL passed to your proxied service
// will have the full path of the socket file prefixed to it.