Regions¶
Regions are named location buckets resolved from a client's GeoIP location
(city/subdivision/country/continent) or a static CIDR mapping, and used
anywhere a "client region" matters — the geo-ip filter-chain step, the
latency step's region bonus, signal-weight zone lookup, and Starlark
script steps' client.geo.
License: Regions and Topology Rules require the pro tier or above. Create/update operations return HTTP 403 on lower tiers. Contact licensing@gslb.nexus to upgrade.
Concepts¶
- Region — a name plus a set of GeoIP selectors (cities, subdivisions, countries, continents). A client's location is matched against every configured region using a fixed precedence chain; the first tier with any match wins.
- Topology Rule — a static CIDR → region-name mapping. Topology rules always take precedence over GeoIP, since they carry private/RFC1918 knowledge GeoIP can never have. Distinct from [Geo Rules(GeoRules.md) — a Geo Rule maps a CIDR straight to one specific pool member (an override); a Topology Rule feeds a region name into the same precedence chain GeoIP selectors use, shared across every pool and service.
Client Matching Order¶
For a given client IP, in order:
- Topology Rules — longest-prefix-match CIDR lookup.
- GeoIP city — case-insensitive city name match. A country-qualified
entry (
"Sydney,AU") beats an unqualified one ("Sydney") for the same name. - GeoIP subdivision — exact match on the full ISO 3166-2 code (e.g.
AU-NSW). Always country-qualified — aGBclient with subdivisionENGnever matches anAU-ENG-shaped selector. - GeoIP country — exact ISO 3166-1 alpha-2 match.
- GeoIP continent — exact match on one of
AF AN AS EU NA OC SA. - No match — the client has no region for this tenant.
The first tier with any match wins; matching does not fall through to a lower tier once a higher tier matches.
Backward Compatibility¶
Before Regions existed, geo-ip filter-chain matching compared a member's
region field directly against the client's raw ISO 3166-1 alpha-2 country
code (e.g. "US", "DE"). A tenant with zero Regions and zero Topology
Rules configured keeps this exact behavior — the region resolver falls back
to the raw country code. Once you create even one Region or Topology Rule for
a tenant, that tenant's resolution switches fully to the precedence chain
above; Member.region values should then hold a region name, not a raw
country code.
Selectors¶
| Selector | Value form | Matching rule |
|---|---|---|
cities |
"Name" or "Name,CC" |
case-insensitive; country-qualified beats unqualified for the same name |
subdivisions |
"CC-SUB" (full ISO 3166-2) |
exact, validated ^[A-Z]{2}-[A-Z0-9]{1,3}$ |
countries |
"CC" (ISO 3166-1 alpha-2) |
exact |
continents |
one of the 7 codes | exact |
_defaultis a reserved name and is rejected as a region name.- A region must have at least one non-empty selector.
- All codes are normalized to upper case and de-duplicated on write.
- City and subdivision selectors require a City-level GeoIP database (GeoLite2-City / GeoIP2-City). Configuring them against a Country-level database is not fatal — those selectors simply never match.
API¶
Regions¶
GET /api/v1/regions — list.
POST /api/v1/regions — create.
PUT /api/v1/regions/{id} — update (same body shape).
DELETE /api/v1/regions/{id} — delete.
Topology Rules¶
GET /api/v1/topology-rules — list.
POST /api/v1/topology-rules — create.
DELETE /api/v1/topology-rules/{id} — delete. There is no update endpoint —
delete and recreate, the same convention as [RPZ rules(RPZ.md).
gslbctl¶
gslbctl regions list
gslbctl regions add au-east --cities "Sydney,AU" --countries AU
gslbctl regions remove <id>
gslbctl topology list
gslbctl topology add 10.0.0.0/8 --region au-east
gslbctl topology remove <id>
Terraform¶
resource "nexus_region" "au_east" {
name = "au-east"
cities = ["Sydney,AU", "Canberra,AU"]
countries = ["AU"]
}
resource "nexus_topology_rule" "internal" {
cidr = "10.0.0.0/8"
region_name = "au-east"
}
nexus_region supports in-place update (all four selector lists are
Optional+Computed). nexus_topology_rule has no update API — every attribute
forces replacement, the same convention as nexus_rpz_rule.
WebUI¶
Fleet → Admin → DNS → Regions (/admin/regions) — create/list/delete
Regions and Topology Rules. Requires region:read/region:write.
Behaviour Notes¶
- Regions and Topology Rules are tenant-scoped: a tenant's clients only ever match that tenant's own configuration, never another tenant's.
- Changes take effect on this node within a few seconds (a background refresh loop mirrors the [RPZ(RPZ.md) precedent); the node that made the write also triggers an immediate local refresh, so it never has to wait for its own change.
- Topology Rule CIDR matching is a longest-prefix-match linear scan per tenant, sorted by prefix length — fine at realistic rule counts. If rule counts grow into the hundreds, this is the place to introduce a radix/patricia trie.
- The [Query Tracer(QueryTracer.md) shows the resolved
clientRegionusing the same resolver the live serving path uses — never a reimplementation — plus which precedence tier actually matched (clientMatchTier) and the client's full resolved location (clientLocation), for debugging why a client landed in a given region.
Known Gaps¶
- Country/subdivision/continent selector pickers (~250 countries / 7 continents / ~3,200 subdivisions) are still plain comma-separated text inputs, not searchable pickers. Lower priority than the city picker below given their much smaller, fixed size — a typo is easy to spot and fix in a short list. Not built.
Searchable city-selector pickerBuilt./admin/regions's Cities field is a typeahead multi-select (webui/src/components/ui/CityPicker.tsx), backed by a ~33k-entry(name, country, population)index bundled as a static asset (webui/public/geonames-cities.json, fetched lazily on first use). Sourced from GeoNames.org (CC BY 4.0) cities15000 extract, not a MaxMind CSV release — this deployment has no MaxMind account to pull MaxMind's own city list from, and GeoNames serves the identical purpose (a searchable name→country index feedingCitySelector{Name, Country}) without one. The dataset is suggestions only, not validation — typing a city not in the curated ~33k (population15,000, or a national capital) still works exactly as before, added as free text on Enter. Regenerating this asset (e.g. after GeoNames publishes an update) is
python3 scripts/generate-city-index.py— not tied to any MaxMind database release cadence, since the two datasets are unrelated.