mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Merge pull request #10105 from caesarxuchao/fix-9287
exclude the port number when checking a request in "kubectl proxy"
This commit is contained in:
commit
b05bd0c59f
@ -18,6 +18,7 @@ package kubectl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
@ -94,8 +95,10 @@ func (f *FilterServer) accept(method, path, host string) bool {
|
||||
}
|
||||
|
||||
func (f *FilterServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
if f.accept(req.Method, req.URL.Path, req.Host) {
|
||||
host, _, _ := net.SplitHostPort(req.Host)
|
||||
if f.accept(req.Method, req.URL.Path, host) {
|
||||
f.delegate.ServeHTTP(rw, req)
|
||||
return
|
||||
}
|
||||
rw.WriteHeader(http.StatusForbidden)
|
||||
rw.Write([]byte("<h3>Unauthorized</h3>"))
|
||||
|
Loading…
Reference in New Issue
Block a user