Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion internal/nginx/config/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ func createLocations(pathRules []state.PathRule, listenerPort int) []http.Locati
return []http.Location{createDefaultRootLocation()}
}

locs := make([]http.Location, 0, lenPathRules) // FIXME(pleshakov): expand with rule.Routes
// To calculate the maximum number of locations, we need to take into account the following:
// 1. Each match rule for a path rule will have one location.
// 2. Each path rule may have an additional location if it contains non-path-only matches.
// 3. There may be an additional location for the default root path.
maxLocs := 1
for _, rules := range pathRules {
maxLocs += len(rules.MatchRules) + 1
}

locs := make([]http.Location, 0, maxLocs)

rootPathExists := false

Expand Down