mirror of
https://github.com/minio/minio.git
synced 2025-03-03 07:10:07 -05:00
server: Redirection should use globalMinioPort with host without port. (#4445)
Currently redirection doesn't work in following scenarios - server started with port ":80" and TLS is configured client requested insecure request on port "80" gets redirected to port 443 and fails.
This commit is contained in:
parent
458f22f37c
commit
975972d57e
@ -449,12 +449,20 @@ func (m *ServerMux) ListenAndServe(certFile, keyFile string) (err error) {
|
||||
// All http requests start to be processed by httpHandler
|
||||
httpHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if tlsEnabled && r.TLS == nil {
|
||||
// It is expected that r.Host might not have port
|
||||
// for standard ports such as "80" and "443".
|
||||
host, port, _ := net.SplitHostPort(r.Host)
|
||||
if port == "" {
|
||||
host = net.JoinHostPort(r.Host, globalMinioPort)
|
||||
} else {
|
||||
host = r.Host
|
||||
}
|
||||
// TLS is enabled but Request is not TLS configured
|
||||
u := url.URL{
|
||||
Scheme: httpsScheme,
|
||||
Opaque: r.URL.Opaque,
|
||||
User: r.URL.User,
|
||||
Host: r.Host,
|
||||
Host: host,
|
||||
Path: r.URL.Path,
|
||||
RawQuery: r.URL.RawQuery,
|
||||
Fragment: r.URL.Fragment,
|
||||
|
Loading…
x
Reference in New Issue
Block a user