First release of dynamic upstream routing for Kong Gateway OSS 3.x.
Highlights
- First-match-wins rules on request headers (exact / PCRE regex / presence)
- Two target modes: Kong Upstream entity, or a templated URL built from
$(uri),$(header.*),$(query.*),$(consumer.*) - SSRF guard enforced twice: schema rejects a templated host without
allowed_hostsat config time, and the resolved host is re-parsed and checked against the allowlist at request time (403) - Fail-closed substitution: unresolved/empty variables return 503, never a mangled URL
- Correct
preserve_hostsemantics, including SNI for https targets (SNI follows the upstream Host header) - Template query string replaces the client query; otherwise the client query passes through
Verified
- 28 unit tests (plain Lua 5.1, no Kong required)
- 19-case e2e suite against Kong 3.9 DB-less with echo upstreams (
e2e/run.sh), both wired into CI
Install
cd plugins/dynamic-upstream
luarocks make kong-dynamic-upstream-0.1.0-1.rockspec
export KONG_PLUGINS=bundled,dynamic-upstream