Introduce ProxyRawPath flag

Setting this flag will configure the upstream proxy to pass encoded urls
as-is.
This commit is contained in:
Fabian Stelzer
2021-09-17 12:37:56 +00:00
parent 733b3fe642
commit d51556515e
4 changed files with 10 additions and 0 deletions
+4
View File
@@ -9,6 +9,10 @@ const (
// Upstreams is a collection of definitions for upstream servers.
type Upstreams struct {
// ProxyRawPath will pass the raw url path to upstream allowing for url's
// like: "/%2F/" which would otherwise be redirected to "/"
ProxyRawPath bool `json:"proxyRawPath,omitempty"`
// Upstream represents the configuration for an upstream server.
// Requests will be proxied to this upstream if the path matches the request path.
Configs []Upstream `json:"configs,omitempty"`
+4
View File
@@ -27,6 +27,10 @@ func NewProxy(upstreams options.Upstreams, sigData *options.SignatureData, write
serveMux: mux.NewRouter(),
}
if upstreams.ProxyRawPath {
m.serveMux.UseEncodedPath()
}
for _, upstream := range sortByPathLongest(upstreams.Configs) {
if upstream.Static {
if err := m.registerStaticResponseHandler(upstream, writer); err != nil {