fix: allow customizing console redirection (#12665)

MinIO might be running inside proxies, and
console while being on another port might not be
reachable on a specific port behind such proxies.

For such scenarios customize the redirect URL
such that console can be redirected to correct
proxy endpoint instead.

fixes #12661
This commit is contained in:
Harshavardhana
2021-07-09 14:27:09 -07:00
committed by GitHub
parent c8cf4c5eb8
commit da0fd5f056
5 changed files with 36 additions and 4 deletions
+6 -3
View File
@@ -21,13 +21,13 @@ import (
"context"
"net"
"net/http"
"net/url"
"path"
"strings"
"sync/atomic"
"time"
"github.com/minio/minio-go/v7/pkg/set"
xnet "github.com/minio/pkg/net"
humanize "github.com/dustin/go-humanize"
"github.com/minio/minio/internal/config/dns"
@@ -183,7 +183,7 @@ func shouldProxy() bool {
// redirectable, this is purely internal function and
// serves only limited purpose on redirect-handler for
// browser requests.
func getRedirectLocation(r *http.Request) *url.URL {
func getRedirectLocation(r *http.Request) *xnet.URL {
resource, err := getResource(r.URL.Path, r.Host, globalDomainNames)
if err != nil {
return nil
@@ -197,11 +197,14 @@ func getRedirectLocation(r *http.Request) *url.URL {
} {
bucket, _ := path2BucketObject(resource)
if path.Clean(bucket) == prefix || resource == slashSeparator {
if globalBrowserRedirectURL != nil {
return globalBrowserRedirectURL
}
hostname, _, _ := net.SplitHostPort(r.Host)
if hostname == "" {
hostname = r.Host
}
return &url.URL{
return &xnet.URL{
Host: net.JoinHostPort(hostname, globalMinioConsolePort),
Scheme: func() string {
scheme := "http"