Communitygithub.com

API 閘道器與反向代理專家

使用 Kong、Nginx、Traefik 等技術設定與最佳化 API 閘道器和反向代理,涵蓋路由、認證與中介軟體。

API 閘道器與反向代理專家 是什麼?

此技能專精於 API 閘道器與反向代理的設定與最佳化,支援 Kong、Nginx、Traefik 等主流技術。它能協助開發者根據流量模式(內部服務、客戶端 API、企業 B2B、第三方 SaaS)選擇合適的認證策略(API Key、JWT、mTLS、OAuth2),並根據需求(外掛生態系、Kubernetes 原生、高效能、雲端託管)推薦對應的閘道器技術。技能深入探討上游路由策略,包括動態服務發現、靜態服務池與多區域地理路由。此外,它還詳細說明了常見的故障模式,如閘道器超時串聯、認證繞過、斷路器抖動、SSL 憑證過期與資源耗盡,並提供具體的症狀、檢測方法與解決方案。最後,透過電商 API 閘道器設定與金絲雀部署失敗的實際案例,展示了如何應用決策樹與進行故障排除,並設有明確的品質閘門與不處理範圍,確保僅專注於核心功能。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/curiositech/windags-skills/tree/HEAD/skills/api-gateway-reverse-proxy-expert

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

API 閘道器與反向代理專家 是做什麼的?

設定並最佳化 API 閘道器與反向代理,以實現路由、認證、速率限制與流量管理。

決策點

認證策略選擇

流量模式與需求
├── 僅限內部服務
│   └── API Key 認證
│       ├── 低複雜度,快速驗證
│       └── Kong: key-auth 外掛,Traefik: forwardAuth
├── 面向客戶的 API,需要工作階段
│   └── JWT 認證
│       ├── 無狀態,包含用戶聲明
│       └── Kong: jwt 外掛,Nginx: lua-resty-jwt
├── 企業 B2B 整合
│   └── mTLS 認證
│       ├── 基於憑證,安全性最高
│       └── Kong: mtls-auth,Nginx: ssl_verify_client
└── 第三方 SaaS 整合
    └── OAuth2 流程
        ├── 令牌交換,委派認證
        └── Kong: oauth2 外掛,AWS API Gateway: authorizer

閘道器技術選擇

需求 → 選擇
├── 需要外掛生態系與 GUI
│   └── Kong Enterprise/OSS
├── Kubernetes 原生,支援自動發現
│   └── Traefik v3 或 Ingress-NGINX
├── 最大效能,最少功能
│   └── Nginx 或 Envoy
└── 雲端管理,無伺服器擴展
    └── AWS API Gateway 或 Azure Application Gateway

上游路由策略

服務架構 → 路由方法
├── 微服務搭配服務發現
│   └── 動態上游目標
│       ├── Consul/Eureka 整合
│       └── 基於健康檢查的負載平衡
├── 靜態後端服務
│   └── 固定上游池
│       ├── 輪詢或最少連接
│       └── 加權路由用於金絲雀部署
└── 多區域部署
    └── 地理路由
        ├── 基於延遲或地理 IP
        └── 容錯轉移至次要區域

故障模式

閘道器超時串聯

症狀: API 回應緩慢(>10 秒)於負載下
檢測: 回應時間飆升,而上游服務報告正常延遲
根本原因: 閘道器超時時間高於上游超時時間,導致請求排隊
修復: 設定閘道器讀取超時 < 上游超時(閘道器:30 秒,上游:25 秒)

認證繞過

症狀: 未經授權的請求到達後端服務
檢測: 後端日誌顯示缺少預期認證標頭的請求
根本原因: 路由順序允許寬鬆規則在認證規則之前匹配
修復: 將認證中介軟體移至全域層級,或確保特定路由在設定中優先出現

斷路器抖動

症狀: 流量高峰期間出現間歇性 503 錯誤
檢測: 斷路器快速開啟/關閉(每分鐘多次)
根本原因: 閾值過於敏感或健康檢查配置錯誤
修復: 調整故障閾值(5 次以上)與恢復時間(至少 30 秒)

SSL 憑證過期

症狀: HTTPS 握手失敗,瀏覽器憑證警告
檢測: SSL 憑證檢查顯示將在 30 天內過期
根本原因: 手動管理憑證,缺乏自動更新機制
修復: 實作 cert-manager (K8s) 或支援自動更新的 ACME 客戶端

資源耗盡

症狀: 閘道器停止接受連接,記憶體/CPU 使用率達 100%
檢測: 連接被拒錯誤,閘道器健康檢查失敗
根本原因: 未設定連接限制或外掛記憶體洩漏
修復: 設定 worker_connections (Nginx) 或連接池限制 (Kong),重新啟動閘道器

實作範例

情境:電商 API 閘道器設定

背景: 為處理訂單、庫存、付款的微服務部署 Kong,並使用 JWT 認證

步驟 1:路由定義

# 首先識別服務端點
services:
  - orders: /api/v1/orders/* → http://orders:8080
  - inventory: /api/v1/inventory/* → http://inventory:8080  
  - payments: /api/v1/payments/* → http://payments:8080

步驟 2:應用決策樹

  • 流量模式:面向客戶的 API → JWT 認證
  • 架構:微服務 → 動態上游目標
  • 需求:需要外掛生態系 → 選擇 Kong

步驟 3:外掛排序

# 按正確順序套用外掛
plugins:
  1. cors (預認證)
  2. jwt (認證) 
  3. rate-limiting (認證後)
  4. request-transformer (最後)

專家 vs 新手:

  • 新手錯誤: 在認證前套用速率限制(匿名用戶消耗配額)
  • 專家做法: 先認證,再根據已認證用戶進行速率限制
  • 新手錯誤: 使用全域 CORS 策略
  • 專家做法: 為不同路由設定不同 CORS(訂單路由允許管理員來源,付款路由限制僅限前端)

失敗情境:金絲雀部署出錯

情況: 將 20% 流量部署到新的訂單服務版本,出現 500 錯誤

檢測流程:

  1. 檢查閘道器指標:500 錯誤率飆升與部署時間相關
  2. 上游健康檢查:新版本健康檢查失敗
  3. 閘道器日誌:上游連接超時

回滾步驟:

# 步驟 1:立即切換流量
kong:
  routes:
    - service: orders-v1
      weight: 100  # 原本是 80
    - service: orders-v2  
      weight: 0    # 原本是 20

# 步驟 2:驗證回滾
curl -H "Authorization: Bearer $JWT" \
  https://api.company.com/orders/health

# 步驟 3:移除失敗的上游
kubectl scale deployment orders-v2 --replicas=0

根本原因分析: 新版本資料庫連接池配置錯誤,導致負載下超時

品質閘門

  • 所有路由皆使用明確路徑匹配(無 catch-all /* 路由)
  • 在業務邏輯外掛前配置認證中介軟體
  • 健康檢查在 5 秒內對健康上游回傳 2xx
  • 斷路器閾值設定:60 秒視窗內 5 次失敗,恢復時間 30 秒
  • TLS 憑證自動更新,到期前仍保有 30 天以上
  • 速率限制根據已認證用戶套用,非全域
  • CORS 策略僅限制為所需的來源網域
  • 閘道器超時(30 秒)< 上游超時(25 秒),以防止串聯
  • 存取日誌包含用於請求追蹤的關聯 ID
  • 閘道器至少部署 2 個副本以實現高可用性

不處理範圍

此技能處理: 閘道器配置、路由規則、認證中介軟體、反向代理設定

不處理:

  • 速率限制演算法設計 → 使用 api-rate-limiting-throttling-expert
  • 服務網格資料平面配置 → 使用 service-mesh-microservices-expert
  • API 規格與設計 → 使用 api-architect
  • 資料庫連接池 → 使用 database-performance-expert
  • 容器編排 → 使用 kubernetes-expert 或 docker-expert
  • SSL 憑證產生 → 使用 security-infrastructure-expert

委派規則:

  • 對於自訂速率限制演算法:「我會配置速率限制外掛,但對於自訂演算法,請使用 api-rate-limiting-throttling-expert」
  • 對於服務發現設定:「我會配置上游目標,但對於服務網格設定,請使用 service-mesh-microservices-expert」

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

curiositech/windags-skills

Expert in 2000s-era music visualization (Milkdrop, AVS, Geiss) and modern WebGL implementations. Specializes in Butterchurn integration, Web Audio API AnalyserNode FFT data, GLSL shaders for audio-reactive visuals, and psychedelic generative art. Activate on "Milkdrop", "music visualization", "WebGL visualizer", "Butterchurn", "audio reactive", "FFT visualization", "spectrum analyzer". NOT for simple bar charts/waveforms (use basic canvas), video editing, or non-audio visuals.

curiositech/windags-skills

Expert legal research agent for finding and scraping expungement data state by state. Knows authoritative sources, URL patterns, Firecrawl configuration, and 2026 legal landscape.

curiositech/windags-skills

Expert in 3D computer vision labeling tools, workflows, and AI-assisted annotation for LiDAR, point clouds, and sensor fusion. Covers SAM4D/Point-SAM, human-in-the-loop architectures, and vertical-specific training strategies. Activate on '3D labeling', 'point cloud annotation', 'LiDAR labeling', 'SAM 3D', 'SAM4D', 'sensor fusion annotation', '3D bounding box', 'semantic segmentation point cloud'. NOT for 2D image labeling (use clip-aware-embeddings), general ML training (use ml-engineer), video annotation without 3D (use computer-vision-pipeline), or VLM prompt engineering (use prompt-engineer).

curiositech/windags-skills

Implement WCAG 2.2 AA/AAA compliance with automated testing, keyboard navigation, screen reader support, and focus management. Activate on: accessibility audit, WCAG compliance, keyboard navigation, screen reader, aria attributes, axe-core, focus trap. NOT for: design-level accessibility review (use design-accessibility-auditor), color contrast only (use css-in-js-architect).

curiositech/windags-skills

Time-blind friendly planning, executive function support, and daily structure for ADHD brains. Specializes in realistic time estimation, dopamine-aware task design, and building systems that actually work for neurodivergent minds.

curiositech/windags-skills

Designs digital experiences for ADHD brains using neuroscience research and UX principles. Expert in reducing cognitive load, time blindness solutions, dopamine-driven engagement, and compassionate design patterns. Activate on 'ADHD design', 'cognitive load', 'accessibility', 'neurodivergent UX', 'time blindness', 'dopamine-driven', 'executive function'. NOT for general accessibility (WCAG only), neurotypical UX design, or simple UI styling without ADHD context.

curiositech/windags-skills

>- Apply crisis decision-making research to agent routing, uncertainty triage, and coordination failure analysis in time-pressured systems. Use when diagnosing handoff failures, analytical paralysis, or expert judgment under incomplete information. NOT for routine coding, simple CRUD design, or static single-agent tasks with complete information.

curiositech/windags-skills

Extend and modify the admin dashboard, developer portal, and operations console. Use when adding new admin tabs, metrics, monitoring features, or internal tools. Activates for dashboard development, analytics, user management, and internal tooling.

curiositech/windags-skills

Conversation patterns and interaction protocols for multi-agent systems. Covers request/response, pub/sub, blackboard, delegation chains, debate, critique, consensus, fan-out/fan-in, supervisor-worker, and peer negotiation. Deep analysis of AutoGen conversation patterns, CrewAI delegation, LangGraph state passing, and FIPA-ACL performatives. Teaches how to design what agents say to each other and in what order. Activate on: "agent conversation", "agent protocol", "multi-agent debate", "agent delegation", "supervisor worker pattern", "agent voting", "consensus protocol", "fan-out fan-in", "agent negotiation", "blackboard pattern", "agent dialogue", "conversation topology", "agent handoff". NOT for: wire format or serialization (use agent-interchange-formats), orchestration infrastructure (use agentic-infrastructure-2026), single agent behavior (use agentic-patterns).

curiositech/windags-skills

Meta-agent for creating new custom agents, skills, and MCP integrations. Expert in agent design, MCP development, skill architecture, and rapid prototyping. Activate on 'create agent', 'new skill', 'MCP server', 'custom tool', 'agent design'. NOT for using existing agents (invoke them directly), general coding (use language-specific skills), or infrastructure setup (use deployment-engineer).

curiositech/windags-skills

AI-powered calendar management and agent-based scheduling coordination. Covers calendar APIs (Google Calendar, CalDAV/iCal), AI scheduling assistants (Reclaim, Clockwise, Motion, Cal.com), building custom calendar agents with MCP, multi-calendar merging, timezone management, focus block protection, meeting fatigue detection, and agent-to-agent meeting negotiation protocols. Activate on: "calendar agent", "AI scheduling", "calendar coordination", "meeting scheduling", "calendar API", "focus time protection", "calendar optimization", "Google Calendar MCP", "Reclaim", "Clockwise", "Motion", "Cal.com", "smart scheduling", "calendar-aware agent", "timezone scheduling", "agent negotiation meetings". NOT for: manual calendar UI component design (use form-validation-architect), project management scheduling or Gantt charts (use project-management-guru-adhd), general time-tracking or pomodoro apps (use adhd-daily-planner for time-awareness), building the agent itself from scratch (use agent-creator).

curiositech/windags-skills

Build and adopt production AI agent infrastructure in 2026. Covers framework selection (LangGraph, CrewAI, AutoGen, MCP), orchestration patterns, evaluation, observability, memory systems, and tool use. Also covers the SOCIAL dimension: how to sell agent infrastructure internally, change management, measuring ROI, building trust in autonomous systems, and scaling adoption across teams. Activate on: "agent infrastructure", "agent framework comparison", "which agent framework", "sell AI tools internally", "agent adoption", "agent observability", "agent evaluation", "MCP architecture", "agentic mesh", "enterprise AI agents", "AI change management", "agent ROI". NOT for: building specific agents (use ai-engineer), designing agent behavior patterns (use agentic-patterns), prompt tuning (use prompt-engineer).

curiositech/windags-skills

Fundamental patterns for effective agentic behavior. Teaches decomposition, tool orchestration, error recovery, context management, quality self-assessment, and knowing when to stop. Model-agnostic principles that make any agent more effective regardless of domain. Activate on: "how should I structure this agent", "agentic workflow", "agent patterns", "multi-step task", "tool orchestration", "/agentic-patterns", "decompose this", "agent best practices", "chain of actions", "when should the agent stop", "agent loop design". NOT for: creating agent infrastructure (use agent-creator), building DAGs (use windags-architect), specific tool implementation.

curiositech/windags-skills

Automated discovery and matching of agent skills for dynamic task routing and capability assessment

curiositech/windags-skills

Cryptographic security for agentic systems — zero-trust agent networking, signed message envelopes (JWS/JWE), capability-based security (ocaps), Merkle tree audit trails, WASM sandboxing, and formal verification. Covers CLI dev tool security, mTLS between agents, permission boundaries (least privilege for AI agents), and supply chain security for skills/plugins. Activate on: "agent security", "zero trust agents", "secure agent communication", "capability-based security", "ocap", "signed messages between agents", "agent audit trail", "sandbox agent execution", "agent permissions", "mTLS agents", "cryptographic verification", "agent supply chain", "OWASP agentic", "prove agent did X", "tamper-proof agent logs". NOT for: application-level SAST scanning (use security-auditor), network firewall rules (use infrastructure), SOC2/HIPAA compliance (organizational), or prompt injection defense (use prompt-engineer).

curiositech/windags-skills

Data structures and serialization formats for agent-to-agent communication. Covers message envelopes, structured output schemas, capability declarations, task handoff payloads, error/retry signaling, and context windows as data structures. Deep comparison of A2A protocol, MCP, OpenAI function calling, and LangChain message types. Teaches when to use rigid schemas vs free-form with validation, typed vs untyped, streaming vs batch. Activate on: "agent message format", "agent communication schema", "agent-to-agent protocol", "A2A protocol", "MCP message format", "structured output for agents", "agent interop", "interchange format", "agent serialization", "task handoff format", "capability declaration". NOT for: what agents say to each other (use agent-conversation-protocols), orchestration topology (use multi-agent-coordination), building agent infrastructure (use agentic-infrastructure-2026).

curiositech/windags-skills

Logic-based agent programming language implementing BDI architecture for practical autonomous agent development

curiositech/windags-skills

>- Design AgentSpeak(L)-style BDI agents with context-guarded plans, selection functions, and intention stacks. Use for interruptible autonomy, agent policy, and multi-agent orchestration in dynamic environments. NOT for simple rule engines, static planners, or centralized workflows.

curiositech/windags-skills

Foundational concurrent computation model where actors communicate exclusively through asynchronous message passing

curiositech/windags-skills

license: Apache-2.0 NOT for unrelated tasks outside this domain.

相關技能