mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 05:36:12 +00:00
Fix proxying of URLs that end in "/" in the pod proxy subresource
Also handles proxying of URLs that have an empty path and don't end in a slash "/" by redirecting to the same location with a slash appended.
This commit is contained in:
@@ -77,7 +77,11 @@ type Transport struct {
|
||||
// RoundTrip implements the http.RoundTripper interface
|
||||
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
// Add reverse proxy headers.
|
||||
req.Header.Set("X-Forwarded-Uri", t.PathPrepend+req.URL.Path)
|
||||
forwardedURI := path.Join(t.PathPrepend, req.URL.Path)
|
||||
if strings.HasSuffix(req.URL.Path, "/") {
|
||||
forwardedURI = forwardedURI + "/"
|
||||
}
|
||||
req.Header.Set("X-Forwarded-Uri", forwardedURI)
|
||||
req.Header.Set("X-Forwarded-Host", t.Host)
|
||||
req.Header.Set("X-Forwarded-Proto", t.Scheme)
|
||||
|
||||
|
Reference in New Issue
Block a user