Merge pull request #1379 from aledbf/catch-all
Fix catch all upstream server
This commit is contained in:
commit
456793fcfe
1 changed files with 13 additions and 0 deletions
|
@ -1124,13 +1124,26 @@ func (ic *GenericController) createServers(data []interface{},
|
||||||
|
|
||||||
// check if ssl passthrough is configured
|
// check if ssl passthrough is configured
|
||||||
sslpt := ic.annotations.SSLPassthrough(ing)
|
sslpt := ic.annotations.SSLPassthrough(ing)
|
||||||
|
|
||||||
|
// default upstream server
|
||||||
du := ic.getDefaultUpstream()
|
du := ic.getDefaultUpstream()
|
||||||
un := du.Name
|
un := du.Name
|
||||||
|
|
||||||
if ing.Spec.Backend != nil {
|
if ing.Spec.Backend != nil {
|
||||||
// replace default backend
|
// replace default backend
|
||||||
defUpstream := fmt.Sprintf("%v-%v-%v", ing.GetNamespace(), ing.Spec.Backend.ServiceName, ing.Spec.Backend.ServicePort.String())
|
defUpstream := fmt.Sprintf("%v-%v-%v", ing.GetNamespace(), ing.Spec.Backend.ServiceName, ing.Spec.Backend.ServicePort.String())
|
||||||
if backendUpstream, ok := upstreams[defUpstream]; ok {
|
if backendUpstream, ok := upstreams[defUpstream]; ok {
|
||||||
un = backendUpstream.Name
|
un = backendUpstream.Name
|
||||||
|
|
||||||
|
// Special case:
|
||||||
|
// ingress only with a backend and no rules
|
||||||
|
// this case defines a "catch all" server
|
||||||
|
defLoc := servers[defServerName].Locations[0]
|
||||||
|
if defLoc.IsDefBackend && len(ing.Spec.Rules) == 0 {
|
||||||
|
defLoc.IsDefBackend = false
|
||||||
|
defLoc.Backend = backendUpstream.Name
|
||||||
|
defLoc.Service = backendUpstream.Service
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue