Skip to content

fix(server): balance every domain and location of a grouped proxy - #5609

Open
waw666waw666 wants to merge 1 commit into
fatedier:devfrom
waw666waw666:fix/group-multiple-routes
Open

waw666waw666 wants to merge 1 commit into
fatedier:devfrom
waw666waw666:fix/group-multiple-routes

Conversation

@waw666waw666

Copy link
Copy Markdown

WHY

An http proxy in a load balancing group can't have more than one route. With

[[proxies]]
name = "foo"
type = "http"
localPort = 8080
customDomains = ["a.example.com", "b.example.com"]  # or locations = ["/x", "/y"]
loadBalancer.group = "web"
loadBalancer.groupKey = "123"

(and the same for a second proxy bar), both proxies fail to start with group params invalid and nothing is routed. HTTPProxy.Run registers the proxy once per domain/location, but HTTPGroupController keeps a single HTTPGroup per group name, which remembers the domain and location of the first registration and rejects every other route. The same happens for https and tcpmux proxies with several customDomains (or customDomains plus subdomain), since HTTPSGroup and TCPMuxGroup also store one domain per group name. The README only asks for customDomains, subdomain and locations to be the same across the group, so this configuration is expected to work.

Groups are now registered per route: the HTTP group registry is keyed by group name, domain, location and routeByHTTPUser, HTTPS by group name and domain, and TCPMux by group name, domain and routeByHTTPUser. Each route gets its own vhost registration with all members of the group behind it, and removing a proxy removes it from every route it joined. Group key and proxy name checks are unchanged. One consequence: two proxies that use the same group name for different domains now each serve their own domain instead of the second one failing with group params invalid.

Tests

  • TestHTTPGroupMultipleRoutes: two proxies with two domains and two locations each; every route balances across both proxies, a wrong group key and a repeated proxy are still rejected, unregistering removes the proxy from every route and the last one releases the routes. Fails on current dev with group params invalid.
  • TestHTTPSAndTCPMuxGroupMultipleDomains: two proxies with two domains each for https and tcpmux. Fails on current dev with group params invalid.
  • New e2e spec [Feature: Group] Load Balancing HTTP with multiple domains and locations: both domains and both locations return responses from both backends. On current dev both proxies fail to start and the request gets no route found.
  • go test -race ./server/... ./pkg/util/vhost/..., full e2e suite (262 passed, 2 skipped), golangci-lint with no new issues.

@kilo-code-bot

kilo-code-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • server/group/group.go
  • server/group/http.go
  • server/group/https.go
  • server/group/routes_test.go
  • server/group/tcpmux.go
  • test/e2e/v1/features/group.go

Validation: Static review only; tests were not executed under the read-only review restrictions.


Reviewed by gpt-6.1-sol · Input: 48 · Output: 6.9K · Cached: 694.4K

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant