1. 安装 Kong

  • 步骤 1: 下载 Kong 二进制文件或使用 Docker 部署
    kong_logo
  • 步骤 2: 解压并配置环境变量
    export KONG_PREFIX=/path/to/kong
    
  • 步骤 3: 安装依赖(如 LuaRocks、OpenResty)
    kong_dependencies

2. 配置 Kong

  • 编辑 kong.conf 文件,设置数据库连接(推荐 PostgreSQL)
    db = postgres://user:password@localhost:5432/kong
    
  • 启用插件(如 bundled 插件集)
    plugins = bundled
    
  • 配置 upstream 和 route 信息
    kong_config

3. 启动 Kong

kong start --init

4. 使用 Kong

  • 创建第一个 API 路由:
    kong curl http://localhost:8001/apis
    
  • 测试 API 响应:
    kong_api
  • 查看 Dashboard 管理界面:
    http://localhost:8000
    

扩展学习

深入理解 Kong 插件系统 🔍
高级路由配置教程 📈