mirror of
https://github.com/minio/minio.git
synced 2025-11-21 02:09:08 -05:00
Set CONSOLE_MINIO_SERVER to 127.0.0.1 by default (#15887)
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
@@ -36,6 +37,7 @@ import (
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/minio/minio-go/v7/pkg/set"
|
||||
"github.com/minio/minio/internal/auth"
|
||||
"github.com/minio/minio/internal/bucket/bandwidth"
|
||||
"github.com/minio/minio/internal/color"
|
||||
@@ -418,6 +420,24 @@ func initConfigSubsystem(ctx context.Context, newObject ObjectLayer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Return the list of address that MinIO server needs to listen on:
|
||||
// - Returning 127.0.0.1 is necessary so Console will be able to send
|
||||
// requests to the local S3 API.
|
||||
// - The returned List needs to be deduplicated as well.
|
||||
func getServerListenAddrs() []string {
|
||||
// Use a string set to avoid duplication
|
||||
addrs := set.NewStringSet()
|
||||
// Listen on local interface to receive requests from Console
|
||||
for _, ip := range mustGetLocalIPs() {
|
||||
if ip != nil && ip.IsLoopback() {
|
||||
addrs.Add(net.JoinHostPort(ip.String(), globalMinioPort))
|
||||
}
|
||||
}
|
||||
// Add the interface specified by the user
|
||||
addrs.Add(globalMinioAddr)
|
||||
return addrs.ToSlice()
|
||||
}
|
||||
|
||||
// serverMain handler called for 'minio server' command.
|
||||
func serverMain(ctx *cli.Context) {
|
||||
signal.Notify(globalOSSignalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
|
||||
@@ -500,7 +520,7 @@ func serverMain(ctx *cli.Context) {
|
||||
getCert = globalTLSCerts.GetCertificate
|
||||
}
|
||||
|
||||
httpServer := xhttp.NewServer([]string{globalMinioAddr}).
|
||||
httpServer := xhttp.NewServer(getServerListenAddrs()).
|
||||
UseHandler(setCriticalErrorHandler(corsHandler(handler))).
|
||||
UseTLSConfig(newTLSConfig(getCert)).
|
||||
UseShutdownTimeout(ctx.Duration("shutdown-timeout")).
|
||||
|
||||
Reference in New Issue
Block a user