Kong is a cloud-native API gateway and platform for managing, securing, and observing APIs and microservices.
It provides rate limiting, authentication, load balancing, and plugin-based extensibility.
flowchart LR
Client([Client]) -->|:8000| Kong[Kong Proxy]
Kong --> ServiceA[Upstream A]
Kong --> ServiceB[Upstream B]
Admin([Admin]) -->|:8001| KongAdmin[Kong Admin API]
Kong --> PG[(PostgreSQL)]
- Clients send requests to the Kong proxy port (8000/8443).
- Kong matches routes and forwards traffic to configured upstream services.
- Plugins (auth, rate-limit, logging, etc.) execute on each request.
- The Admin API (port 8001) manages routes, services, consumers, and plugins.
- PostgreSQL stores all Kong configuration and plugin state.
- Kong image:
kong:3.7 - Database image:
postgres:16-alpine - Container names:
kong,kong-db,kong-migration - Proxy port:
8000(HTTP),8443(HTTPS) - Admin API:
http://<host-ip>:8001 - PostgreSQL: internal only
Set via .env (copy from .env.example):
KONG_PROXY_PORT(default:8000)KONG_PROXY_SSL_PORT(default:8443)KONG_ADMIN_PORT(default:8001)KONG_PG_USER(default:kong)KONG_PG_PASSWORD(default:changeme)KONG_PG_DATABASE(default:kong)
From the repository root:
cd kong
cp .env.example .env
docker compose up -dWait for migrations to complete, then verify:
curl http://localhost:8001/statusOpen:
- Proxy:
http://localhost:8000 - Admin API:
http://localhost:8001
Useful commands:
docker compose ps
docker compose logs -f kong
docker compose restart
docker compose down- Add a service and route via the Admin API:
# Create a service
curl -i -X POST http://localhost:8001/services \
--data name=example-service \
--data url=http://httpbin.org
# Create a route
curl -i -X POST http://localhost:8001/services/example-service/routes \
--data paths[]=/example- Enable plugins (rate limiting, key-auth, JWT, etc.) per service or globally.
- Use Kong Manager UI (available in Kong Enterprise) or tools like Konga for a web dashboard.
- Export configuration with
deckCLI for version-controlled gateway config.
- Change default database credentials before exposing externally.
- The migration container runs once and exits — this is expected behavior.
- Admin API should not be exposed publicly in production; restrict access via firewall or bind to localhost.
- See Kong docs for full plugin and configuration reference.