Merge pull request #1118 from zjj2wry/limit-rate

feat(#733)Support nginx bandwidth control
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-08-13 11:30:57 -03:00 committed by GitHub
commit 854da227d3
6 changed files with 84 additions and 12 deletions

View file

@ -387,6 +387,8 @@ func NewDefault() Configuration {
CustomHTTPErrors: []int{},
WhitelistSourceRange: []string{},
SkipAccessLogURLs: []string{},
LimitRate: 0,
LimitRateAfter: 0,
},
UpstreamKeepaliveConnections: 0,
LimitConnZoneVariable: defaultLimitConnZoneVariable,

View file

@ -404,6 +404,18 @@ func buildRateLimit(input interface{}) []string {
limits = append(limits, limit)
}
if loc.RateLimit.LimitRateAfter > 0 {
limit := fmt.Sprintf("limit_rate_after %vk;",
loc.RateLimit.LimitRateAfter)
limits = append(limits, limit)
}
if loc.RateLimit.LimitRate > 0 {
limit := fmt.Sprintf("limit_rate %vk;",
loc.RateLimit.LimitRate)
limits = append(limits, limit)
}
return limits
}