mirror of
https://github.com/minio/minio.git
synced 2025-04-24 04:10:43 -04:00
introduce MINIO_BROWSER_REDIRECT env to enable/disable auto-redirect (#18025)
This commit is contained in:
parent
ed2c2a285f
commit
32890342ce
@ -150,7 +150,7 @@ func minioConfigToConsoleFeatures() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// pass the console subpath configuration
|
// pass the console subpath configuration
|
||||||
if value := env.Get(config.EnvBrowserRedirectURL, ""); value != "" {
|
if globalBrowserRedirectURL != nil {
|
||||||
subPath := path.Clean(pathJoin(strings.TrimSpace(globalBrowserRedirectURL.Path), SlashSeparator))
|
subPath := path.Clean(pathJoin(strings.TrimSpace(globalBrowserRedirectURL.Path), SlashSeparator))
|
||||||
if subPath != SlashSeparator {
|
if subPath != SlashSeparator {
|
||||||
os.Setenv("CONSOLE_SUBPATH", subPath)
|
os.Setenv("CONSOLE_SUBPATH", subPath)
|
||||||
@ -649,6 +649,7 @@ func handleCommonEnvVars() {
|
|||||||
}
|
}
|
||||||
globalBrowserRedirectURL = u
|
globalBrowserRedirectURL = u
|
||||||
}
|
}
|
||||||
|
globalBrowserRedirect = env.Get(config.EnvBrowserRedirect, config.EnableOn) == config.EnableOn
|
||||||
}
|
}
|
||||||
|
|
||||||
if serverURL := env.Get(config.EnvMinIOServerURL, ""); serverURL != "" {
|
if serverURL := env.Get(config.EnvMinIOServerURL, ""); serverURL != "" {
|
||||||
|
@ -152,7 +152,7 @@ func setBrowserRedirectMiddleware(h http.Handler) http.Handler {
|
|||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
read := r.Method == http.MethodGet || r.Method == http.MethodHead
|
read := r.Method == http.MethodGet || r.Method == http.MethodHead
|
||||||
// Re-direction is handled specifically for browser requests.
|
// Re-direction is handled specifically for browser requests.
|
||||||
if guessIsBrowserReq(r) && read {
|
if guessIsBrowserReq(r) && read && globalBrowserRedirect {
|
||||||
// Fetch the redirect location if any.
|
// Fetch the redirect location if any.
|
||||||
if u := getRedirectLocation(r); u != nil {
|
if u := getRedirectLocation(r); u != nil {
|
||||||
// Employ a temporary re-direct.
|
// Employ a temporary re-direct.
|
||||||
|
@ -152,6 +152,9 @@ var (
|
|||||||
// and it is automatically deduced.
|
// and it is automatically deduced.
|
||||||
globalBrowserRedirectURL *xnet.URL
|
globalBrowserRedirectURL *xnet.URL
|
||||||
|
|
||||||
|
// Disable redirect, default is enabled.
|
||||||
|
globalBrowserRedirect bool
|
||||||
|
|
||||||
// This flag is set to 'true' when MINIO_UPDATE env is set to 'off'. Default is false.
|
// This flag is set to 'true' when MINIO_UPDATE env is set to 'off'. Default is false.
|
||||||
globalInplaceUpdateDisabled = false
|
globalInplaceUpdateDisabled = false
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ const (
|
|||||||
EnvMinIOCallhomeFrequency = "MINIO_CALLHOME_FREQUENCY"
|
EnvMinIOCallhomeFrequency = "MINIO_CALLHOME_FREQUENCY"
|
||||||
|
|
||||||
EnvMinIOServerURL = "MINIO_SERVER_URL"
|
EnvMinIOServerURL = "MINIO_SERVER_URL"
|
||||||
|
EnvBrowserRedirect = "MINIO_BROWSER_REDIRECT" // On by default
|
||||||
EnvBrowserRedirectURL = "MINIO_BROWSER_REDIRECT_URL"
|
EnvBrowserRedirectURL = "MINIO_BROWSER_REDIRECT_URL"
|
||||||
EnvRootDriveThresholdSize = "MINIO_ROOTDRIVE_THRESHOLD_SIZE"
|
EnvRootDriveThresholdSize = "MINIO_ROOTDRIVE_THRESHOLD_SIZE"
|
||||||
EnvRootDiskThresholdSize = "MINIO_ROOTDISK_THRESHOLD_SIZE" // Deprecated Sep 2023
|
EnvRootDiskThresholdSize = "MINIO_ROOTDISK_THRESHOLD_SIZE" // Deprecated Sep 2023
|
||||||
|
Loading…
x
Reference in New Issue
Block a user