Kong Gateway Quickstart

07 May 2024 in TIL

A $dayjob related TIL today. Here's how to quickly deploy Kong Gateway locally with the Dev Portal enabled (you'll need an enterprise license).

This is useful for testing things locally.

Run the Gateway:

curl -Ls https://get.konghq.com/quickstart | PROXY_PORT=80 bash -s -- -m \
-e KONG_PASSWORD=changeme \
-e KONG_ADMIN_GUI_URL=http://manager.example \
-e KONG_ADMIN_GUI_API_URL=http://admin.example \
-e KONG_PORTAL_API_URL=http://portalapi.example \
-e KONG_PORTAL_GUI_HOST=portal.example \
-e KONG_PORTAL_SESSION_CONF='{"cookie_name": "portal_session", "secret": "PORTAL_SUPER_SECRET", "storage": "kong", "cookie_secure": false, "cookie_domain":".example"}'
-e KONG_PORTAL="on" \
-t 3.4

Create routes that proxy based on host name:

curl -X POST localhost:8001/services -d name=admin -d url=http://localhost:8001
curl -X POST localhost:8001/services -d name=manager -d url=http://localhost:8002
curl -X POST localhost:8001/services -d name=portal -d url=http://localhost:8003
curl -X POST localhost:8001/services -d name=portalapi -d url=http://localhost:8004
curl -X POST localhost:8001/services/admin/routes -d hosts=admin.example
curl -X POST localhost:8001/services/manager/routes -d hosts=manager.example
curl -X POST localhost:8001/services/portal/routes -d hosts=portal.example
curl -X POST localhost:8001/services/portalapi/routes -d hosts=portalapi.example

Add those domains to your /etc/hosts file:

echo ' proxy.example admin.example manager.example portal.example portalapi.example
' | sudo tee -a /etc/hosts

Now you can visit http://manager.example and log in with kong_admin / changeme.