Kong Gateway is a Lua application running in Nginx. Kong Gateway is distributed along with OpenResty, which is a bundle of modules that extend the lua-nginx-module.
Kong 是一个基于 Nginx 上运行的 Lua 程序。它改善了 Nginx 基于静态配置的缺点,可以动态添加插件和热部署。

Service是后端服务的抽象。
Routes是 client 到后端服务的路由规则的抽象。如,为不同的 client 设置不同的认证规则。
Kong 的 routes 有两种模式 traditional_compat 和 expressions 。
traditional_compat :旧的基于通配符等匹配优先级的模式。expressions :新的基于表达式的匹配模式。Upstreams是一个运维对象,在 Services 和真正的后台 API 服务之间,用来负载均衡。
Plugins是用 lua 或 go 编写的插件,分为 Kong 官方提供的插件和第三方插件。
Kong 支持三类协议:HTTP/HTTPS,TCL/TLS 和 GRPC/GRPCS。每种协议由不同的参数组成:
http: methods, hosts, headers, paths (and snis, if https)tcp: sources, destinations (and snis, if tls)grpc: hosts, headers, paths (and snis, if grpcs)Kong 支持按 HTTP header、URL、method、源地址、目标地址、Server Name Indication 来路由请求。
Kong 默认以RFC 3986协议对请求的路径处理。
按最多匹配的规则来路由。
The rule is: when evaluating a request, Kong Gateway first tries to match the routes with the most rules.
当所有匹配规则检查完,Kong 会通过下层的 Nginx 模块发送请求。Response 返回之后,Kong 再经过header_filter和body_filter两个 hook 来修改 response header 和 body。
有两种配置方式来路由 wss 请求:
Kong 支持两类负载均衡方式
这部分跟 Nginx 类似。