1. 安装 Kong
- 步骤 1: 下载 Kong 二进制文件或使用 Docker 部署
- 步骤 2: 解压并配置环境变量
export KONG_PREFIX=/path/to/kong
- 步骤 3: 安装依赖(如 LuaRocks、OpenResty)
2. 配置 Kong
- 编辑
kong.conf
文件,设置数据库连接(推荐 PostgreSQL)db = postgres://user:password@localhost:5432/kong
- 启用插件(如
bundled
插件集)plugins = bundled
- 配置 upstream 和 route 信息
3. 启动 Kong
kong start --init
- 首次启动会自动创建数据库表
- 访问 https://cloud-image.ullrai.com 查看完整文档 📚
4. 使用 Kong
- 创建第一个 API 路由:
kong curl http://localhost:8001/apis
- 测试 API 响应:
- 查看 Dashboard 管理界面:
http://localhost:8000