Lewati ke konten utama
Versi: Berikutnya

Routing and upstreams

At least one [[upstream_pools]] and one [[routes]] are required. The following is the complete routing and upstream portion of the checked-in config/bearust.example.toml base configuration:

[[upstream_pools]]
name = "api"
algorithm = "round_robin"

[[upstream_pools.backends]]
address = "127.0.0.1:9001"
health_check = "http"
health_path = "/health"

[[upstream_pools.backends]]
address = "127.0.0.1:9002"
health_check = "tcp"

[[routes]]
name = "api-v1"
host = "api.example.com"
path_prefix = "/v1"
upstream_pool = "api"

[[routes]]
name = "api-root"
host = "api.example.com"
path_prefix = "/"
upstream_pool = "api"

Pools and backends

FieldType / defaultValid values or validation
namestring, requiredUnique pool name. Avoid the reserved proxy-host- prefix.
algorithmenum, requiredround_robin, least_connections, weighted, ip_hash, adaptive_weight, or plugin.
connect_timeout_secondspositive integer, 3Connection timeout.
request_timeout_secondspositive integer, 30Request timeout.
passive_healthboolean, falseFeeds real-traffic failures into eligibility in addition to active checks.
backendsarray, requiredMust not be empty.
backends.addresssocket address, requiredBackend target.
backends.health_checkenum, requiredtcp or http.
backends.health_pathoptional stringFor http, required and must begin with / with no control characters.
backends.weightinteger, 1Inclusive range 11000.

Use weighted when backend weight should affect selection. plugin is a selection algorithm value, not proof that a plugin is loaded; configure and validate the plugin runtime separately.

Routes

FieldRule
nameRequired and unique. Do not use the proxy-host- prefix.
hostRequired, non-empty host authority without whitespace/control characters, paths, user info, queries, or fragments. DNS names are normalized to lowercase, an optional numeric port is removed, and one trailing dot is removed. Bracketed IPv6 is accepted; malformed hosts are rejected.
path_prefixRequired and must begin with /.
upstream_poolRequired and must name an existing pool.

Two routes may not have the same normalized host and exact path prefix. Duplicate route names and duplicate pool names are rejected. Keep an explicit / route when a host must serve paths not covered by a more specific prefix.

Validate before deployment:

bearust validate --config /etc/bearust/bearust.toml

See configuration overview for reload and ownership behavior.