Add configoption to exclude routes from tls upgrading (#2203)
* Add configoption to exclude routes from tls upgrading * Add tests for IsLocationInLocationList * Seperate elements in NoTLSRedirectLocations by comma * Set NoTLSRedirectLocations to "/.well-known/acme-challenge/" by default * Remove trailing slash from "/.well-known/acme-challenge" default
This commit is contained in:
parent
977cfcb4c7
commit
94deb3a01a
5 changed files with 60 additions and 1 deletions
|
|
@ -129,6 +129,7 @@ var (
|
|||
"buildRateLimit": buildRateLimit,
|
||||
"buildResolvers": buildResolvers,
|
||||
"buildUpstreamName": buildUpstreamName,
|
||||
"isLocationInLocationList": isLocationInLocationList,
|
||||
"isLocationAllowed": isLocationAllowed,
|
||||
"buildLogFormatUpstream": buildLogFormatUpstream,
|
||||
"buildDenyVariable": buildDenyVariable,
|
||||
|
|
@ -513,6 +514,28 @@ func buildRateLimit(input interface{}) []string {
|
|||
return limits
|
||||
}
|
||||
|
||||
func isLocationInLocationList(location interface{}, rawLocationList string) bool {
|
||||
loc, ok := location.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", location)
|
||||
return false
|
||||
}
|
||||
|
||||
locationList := strings.Split(rawLocationList, ",")
|
||||
|
||||
for _, locationListItem := range locationList {
|
||||
locationListItem = strings.Trim(locationListItem, " ")
|
||||
if locationListItem == "" {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(loc.Path, locationListItem) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func isLocationAllowed(input interface{}) bool {
|
||||
loc, ok := input.(*ingress.Location)
|
||||
if !ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue