Kong plugin for dynamically change upstream url based on cookies.
This Kong plugin allows you to route client request based on user cookies. It is inspired by Route By Header.
curl -X POST http://kong:8001/services/{service}/plugins \
--data "name=route-by-cookie" \
--data "config.target_upstream=new-upstream" \
--data "config.cookie_name=COOKIE_NAME" \
--data "config.cookie_val=value"
curl -X POST http://kong:8001/routes/{route_id}/plugins \
--data "name=route-by-cookie" \
--data "config.target_upstream=new-upstream" \
--data "config.cookie_name=COOKIE_NAME" \
--data "config.cookie_val=value"
target_upstream
: Kong Upstream which we want to route the request toconfig.cookie_name
: Cookie name which we will check atconfig.cookie_val
: If user's cookie value equals this, Kong will route the user totarget_upstream
Kong >= 2.0
Should work with 1.X but not tested
luarocks install kong-plugin-route-by-cookie
You need Pongo to run the tests.
pongo run
Expected output:
Kong version: 2.2.0
βββββββββββββββββββββββββββββββββββββββββββββββββ
49 successes / 0 failures / 0 errors / 0 pending : 5.379104 seconds