From fb8d0d7cf77b5115034be55fa282363d2d883acf Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 23 Dec 2018 03:08:21 -0800 Subject: [PATCH] Add support for hostname lookups instead of IPs in MINIO_PUBLIC_IPS (#7018) DNS names will be resolved to their respective IPs if specified in MINIO_PUBLIC_IPS. Fixes #6862 --- cmd/common-main.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/common-main.go b/cmd/common-main.go index ed6c6148d..fc4e2c263 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -245,12 +245,22 @@ func handleCommonEnvVars() { minioEndpointsEnv, ok := os.LookupEnv("MINIO_PUBLIC_IPS") if ok { minioEndpoints := strings.Split(minioEndpointsEnv, ",") - for i, ip := range minioEndpoints { - if net.ParseIP(ip) == nil { - logger.FatalIf(errInvalidArgument, "Unable to initialize Minio server with invalid MINIO_PUBLIC_IPS[%d]: %s", i, ip) + var domainIPs = set.NewStringSet() + for _, endpoint := range minioEndpoints { + if net.ParseIP(endpoint) == nil { + // Checking if the IP is a DNS entry. + addrs, err := net.LookupHost(endpoint) + if err != nil { + logger.FatalIf(err, "Unable to initialize Minio server with [%s] invalid entry found in MINIO_PUBLIC_IPS", endpoint) + } + for _, addr := range addrs { + domainIPs.Add(addr) + } + continue } + domainIPs.Add(endpoint) } - updateDomainIPs(set.CreateStringSet(minioEndpoints...)) + updateDomainIPs(domainIPs) } else { // Add found interfaces IP address to global domain IPS, // loopback addresses will be naturally dropped.