mirror of
https://github.com/minio/minio.git
synced 2025-07-12 02:21:05 -04:00
Add check for reverse proxy setups (#18310)
Add check for reverse proxy setups, to skip check for paths being served by different port on same address.
This commit is contained in:
parent
06f59ad631
commit
4d40ee00e9
@ -915,33 +915,35 @@ func CreatePoolEndpoints(serverAddr string, poolArgs ...[][]string) ([]Endpoints
|
|||||||
}
|
}
|
||||||
|
|
||||||
orchestrated := IsKubernetes() || IsDocker()
|
orchestrated := IsKubernetes() || IsDocker()
|
||||||
if !orchestrated {
|
reverseProxy := (env.Get("_MINIO_REVERSE_PROXY", "") != "") && ((env.Get("MINIO_CI_CD", "") != "") || (env.Get("CI", "") != ""))
|
||||||
|
// If not orchestrated
|
||||||
|
if !orchestrated &&
|
||||||
|
// and not setup in reverse proxy
|
||||||
|
!reverseProxy {
|
||||||
// Check whether same path is not used in endpoints of a host on different port.
|
// Check whether same path is not used in endpoints of a host on different port.
|
||||||
// Only verify this on baremetal setups, DNS is not available in orchestrated
|
// Only verify this on baremetal setups, DNS is not available in orchestrated
|
||||||
// environments so we can't do much here.
|
// environments so we can't do much here.
|
||||||
{
|
pathIPMap := make(map[string]set.StringSet)
|
||||||
pathIPMap := make(map[string]set.StringSet)
|
hostIPCache := make(map[string]set.StringSet)
|
||||||
hostIPCache := make(map[string]set.StringSet)
|
for _, endpoint := range endpoints {
|
||||||
for _, endpoint := range endpoints {
|
host := endpoint.Hostname()
|
||||||
host := endpoint.Hostname()
|
hostIPSet, ok := hostIPCache[host]
|
||||||
hostIPSet, ok := hostIPCache[host]
|
if !ok {
|
||||||
if !ok {
|
var err error
|
||||||
var err error
|
hostIPSet, err = getHostIP(host)
|
||||||
hostIPSet, err = getHostIP(host)
|
if err != nil {
|
||||||
if err != nil {
|
return nil, setupType, config.ErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("host '%s' cannot resolve: %s", host, err))
|
||||||
return nil, setupType, config.ErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("host '%s' cannot resolve: %s", host, err))
|
|
||||||
}
|
|
||||||
hostIPCache[host] = hostIPSet
|
|
||||||
}
|
}
|
||||||
if IPSet, ok := pathIPMap[endpoint.Path]; ok {
|
hostIPCache[host] = hostIPSet
|
||||||
if !IPSet.Intersection(hostIPSet).IsEmpty() {
|
}
|
||||||
return nil, setupType,
|
if IPSet, ok := pathIPMap[endpoint.Path]; ok {
|
||||||
config.ErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("same path '%s' can not be served by different port on same address", endpoint.Path))
|
if !IPSet.Intersection(hostIPSet).IsEmpty() {
|
||||||
}
|
return nil, setupType,
|
||||||
pathIPMap[endpoint.Path] = IPSet.Union(hostIPSet)
|
config.ErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("same path '%s' can not be served by different port on same address", endpoint.Path))
|
||||||
} else {
|
|
||||||
pathIPMap[endpoint.Path] = hostIPSet
|
|
||||||
}
|
}
|
||||||
|
pathIPMap[endpoint.Path] = IPSet.Union(hostIPSet)
|
||||||
|
} else {
|
||||||
|
pathIPMap[endpoint.Path] = hostIPSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1113,32 +1115,34 @@ func CreateEndpoints(serverAddr string, args ...[]string) (Endpoints, SetupType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
orchestrated := IsKubernetes() || IsDocker()
|
orchestrated := IsKubernetes() || IsDocker()
|
||||||
if !orchestrated {
|
reverseProxy := (env.Get("_MINIO_REVERSE_PROXY", "") != "") && ((env.Get("MINIO_CI_CD", "") != "") || (env.Get("CI", "") != ""))
|
||||||
|
// If not orchestrated
|
||||||
|
if !orchestrated &&
|
||||||
|
// and not setup in reverse proxy
|
||||||
|
!reverseProxy {
|
||||||
// Check whether same path is not used in endpoints of a host on different port.
|
// Check whether same path is not used in endpoints of a host on different port.
|
||||||
// Only verify this on baremetal setups, DNS is not available in orchestrated
|
// Only verify this on baremetal setups, DNS is not available in orchestrated
|
||||||
// environments so we can't do much here.
|
// environments so we can't do much here.
|
||||||
{
|
pathIPMap := make(map[string]set.StringSet)
|
||||||
pathIPMap := make(map[string]set.StringSet)
|
hostIPCache := make(map[string]set.StringSet)
|
||||||
hostIPCache := make(map[string]set.StringSet)
|
for _, endpoint := range endpoints {
|
||||||
for _, endpoint := range endpoints {
|
host := endpoint.Hostname()
|
||||||
host := endpoint.Hostname()
|
hostIPSet, ok := hostIPCache[host]
|
||||||
hostIPSet, ok := hostIPCache[host]
|
if !ok {
|
||||||
if !ok {
|
hostIPSet, err = getHostIP(host)
|
||||||
hostIPSet, err = getHostIP(host)
|
if err != nil {
|
||||||
if err != nil {
|
return endpoints, setupType, config.ErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("host '%s' cannot resolve: %s", host, err))
|
||||||
return endpoints, setupType, config.ErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("host '%s' cannot resolve: %s", host, err))
|
|
||||||
}
|
|
||||||
hostIPCache[host] = hostIPSet
|
|
||||||
}
|
}
|
||||||
if IPSet, ok := pathIPMap[endpoint.Path]; ok {
|
hostIPCache[host] = hostIPSet
|
||||||
if !IPSet.Intersection(hostIPSet).IsEmpty() {
|
}
|
||||||
return endpoints, setupType,
|
if IPSet, ok := pathIPMap[endpoint.Path]; ok {
|
||||||
config.ErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("same path '%s' can not be served by different port on same address", endpoint.Path))
|
if !IPSet.Intersection(hostIPSet).IsEmpty() {
|
||||||
}
|
return endpoints, setupType,
|
||||||
pathIPMap[endpoint.Path] = IPSet.Union(hostIPSet)
|
config.ErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("same path '%s' can not be served by different port on same address", endpoint.Path))
|
||||||
} else {
|
|
||||||
pathIPMap[endpoint.Path] = hostIPSet
|
|
||||||
}
|
}
|
||||||
|
pathIPMap[endpoint.Path] = IPSet.Union(hostIPSet)
|
||||||
|
} else {
|
||||||
|
pathIPMap[endpoint.Path] = hostIPSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user