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:
bashcurl -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_GUI_PROTOCOL=http \-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" \-e KONG_LICENSE_DATA \-t 3.4
Create routes that proxy based on host name:
bashcurl -X POST localhost:8001/services -d name=admin -d url=http://localhost:8001curl -X POST localhost:8001/services -d name=manager -d url=http://localhost:8002curl -X POST localhost:8001/services -d name=portal -d url=http://localhost:8003curl -X POST localhost:8001/services -d name=portalapi -d url=http://localhost:8004curl -X POST localhost:8001/services/admin/routes -d hosts=admin.examplecurl -X POST localhost:8001/services/manager/routes -d hosts=manager.examplecurl -X POST localhost:8001/services/portal/routes -d hosts=portal.examplecurl -X POST localhost:8001/services/portalapi/routes -d hosts=portalapi.example
Add those domains to your /etc/hosts file:
bashecho '127.0.0.1 proxy.example127.0.0.1 admin.example127.0.0.1 manager.example127.0.0.1 portal.example127.0.0.1 portalapi.example' | sudo tee -a /etc/hosts
Now you can visit http://manager.example and log in with kong_admin / changeme.