Production-ready Kong API Gateway deployment with Docker Compose.
- Authentication - JWT, OAuth2, API keys, and more
- Rate Limiting - Protect backend services from abuse
- Traffic Control - Request/response transformations
- Load Balancing - Distribute traffic across multiple backends
- Health Checks - Active and passive health monitoring
- Plugin Ecosystem - 100+ official and community plugins
- AI Gateway - Native LLM provider integration (Kong 3.9+)
- Docker Engine 20.10+
- Docker Compose 2.0+
- 2GB RAM minimum
./setup.shThe setup script will:
- Create
.envfromdefault.envif not present - Start PostgreSQL database
- Run database migrations
- Launch Kong Gateway
| Service | HTTP | HTTPS |
|---|---|---|
| Proxy | :8000 |
:8443 |
| Admin API | :8001 |
:8444 |
| Kong Manager | :8002 |
:8445 |
Verify the installation:
curl http://localhost:8001/statusCopy and edit the environment file:
cp default.env .env| Variable | Default | Description |
|---|---|---|
KONG_VERSION |
3.9 |
Kong Gateway version |
KONG_PG_DATABASE |
kong |
PostgreSQL database name |
KONG_PG_USER |
kong |
PostgreSQL username |
KONG_PG_PASSWORD |
kong |
PostgreSQL password |
Place Kong configuration in config/kong.yaml:
_format_version: "3.0"
services:
- name: my-service
url: https://api.example.com
routes:
- name: my-route
paths:
- /api┌─────────────────┐
│ kong-database │ PostgreSQL 17 (persistent storage)
└────────┬────────┘
│
▼
┌─────────────────┐
│ kong-migrations │ Database schema bootstrap
└────────┬────────┘
│
▼
┌─────────────────┐
│ kong │ Kong Gateway 3.9 (read-only container)
└─────────────────┘
Container dependencies use health check conditions to ensure proper startup ordering.
docker compose up -ddocker compose downdocker compose logs -f kongdocker exec kong-database pg_dump -U kong kong > backup.sqlcat backup.sql | docker exec -i kong-database psql -U kong kongNote: Upgrades may require service downtime. Always backup before upgrading.
- Update
KONG_VERSIONin.env - Run migrations:
docker compose run --rm kong kong migrations up --vv
docker compose run --rm kong kong migrations finish --vv- Restart Kong:
docker compose up -d kongThis deployment implements several security measures:
- Read-only container filesystem
no-new-privilegessecurity option- Config directory mounted read-only
- tmpfs volumes for runtime data
- Change default database credentials
- Enable TLS certificates for all endpoints
- Restrict Admin API access to trusted networks
- Configure firewall rules for exposed ports
- Set up log aggregation and monitoring
MIT License - See LICENSE for details.