From 9acfec541845fb830b84968ae2bdecf880716af6 Mon Sep 17 00:00:00 2001 From: Pieter Raubenheimer Date: Wed, 1 Jun 2016 18:36:40 +0100 Subject: [PATCH] Fix cleaned URL path in proxy --- middleware/proxy/proxy.go | 5 +++++ middleware/proxy/proxy_test.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go index b7b6c3274..264444d9a 100644 --- a/middleware/proxy/proxy.go +++ b/middleware/proxy/proxy.go @@ -165,6 +165,11 @@ func createUpstreamRequest(r *http.Request) *http.Request { outreq := new(http.Request) *outreq = *r // includes shallow copies of maps, but okay + // Restore URL Path if it has been modified + if outreq.URL.RawPath != "" { + outreq.URL.Opaque = outreq.URL.RawPath + } + // Remove hop-by-hop headers to the backend. Especially // important is "Connection" because we want a persistent // connection, regardless of what the client sent to us. This diff --git a/middleware/proxy/proxy_test.go b/middleware/proxy/proxy_test.go index b07ff7df9..592b782ea 100644 --- a/middleware/proxy/proxy_test.go +++ b/middleware/proxy/proxy_test.go @@ -309,6 +309,8 @@ func TestUnixSocketProxyPaths(t *testing.T) { {"/proxy/hello", "/proxy", fmt.Sprintf(greeting, "/hello")}, {"/proxy/foo/bar", "/proxy", fmt.Sprintf(greeting, "/foo/bar")}, {"/proxy/?foo=bar", "/proxy", fmt.Sprintf(greeting, "/?foo=bar")}, + {"/queues/%2F/fetchtasks", "", fmt.Sprintf(greeting, "/queues/%2F/fetchtasks")}, + {"/queues/%2F/fetchtasks?foo=bar", "", fmt.Sprintf(greeting, "/queues/%2F/fetchtasks?foo=bar")}, } for _, test := range tests {