From 4bea9948f762c460f6928a23b65e4a96164b066d Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Tue, 10 Nov 2020 18:03:42 +0000 Subject: [PATCH] WIP: Fix proxy mapping to upstreams --- pkg/upstream/http.go | 3 --- pkg/upstream/proxy_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pkg/upstream/http.go b/pkg/upstream/http.go index a6e948c3..c6d5540e 100644 --- a/pkg/upstream/http.go +++ b/pkg/upstream/http.go @@ -40,9 +40,6 @@ var SignatureHeaders = []string{ // newHTTPUpstreamProxy creates a new httpUpstreamProxy that can serve requests // to a single upstream host. func newHTTPUpstreamProxy(upstream options.Upstream, u *url.URL, sigData *options.SignatureData, errorHandler ProxyErrorHandler) http.Handler { - // Set path to empty so that request paths start at the server root - u.Path = "" - // Create a ReverseProxy proxy := newReverseProxy(u, upstream, errorHandler) diff --git a/pkg/upstream/proxy_test.go b/pkg/upstream/proxy_test.go index e834bc60..592c62b0 100644 --- a/pkg/upstream/proxy_test.go +++ b/pkg/upstream/proxy_test.go @@ -54,6 +54,11 @@ var _ = Describe("Proxy Suite", func() { Static: true, StaticCode: &ok, }, + { + ID: "http-backend-with-subpath", + Path: "/http-subpath/", + URI: fmt.Sprintf("%s/subpath/", serverAddr), + }, } var err error @@ -179,5 +184,26 @@ var _ = Describe("Proxy Suite", func() { raw: "404 page not found\n", }, }), + Entry("with a request to the HTTP service registered under a subpath", &proxyTableInput{ + target: "http://example.localhost/http-subpath/1234", + response: testHTTPResponse{ + code: 200, + header: map[string][]string{ + gapUpstream: {"http-backend-with-subpath"}, + contentType: {applicationJSON}, + }, + request: testHTTPRequest{ + Method: "GET", + URL: "http://example.localhost/subpath/http-subpath/1234", + Header: map[string][]string{ + "Gap-Auth": {""}, + "Gap-Signature": {"sha256 ofB1u6+FhEUbFLc3/uGbJVkl7GaN4egFqVvyO3+2I1w="}, + }, + Body: []byte{}, + Host: "example.localhost", + RequestURI: "http://example.localhost/subpath/http-subpath/1234", + }, + }, + }), ) })