Lua 如何从 Envoy 获取域名

How to get domain from Envoy by Lua

我想通过不同的域路由请求。我读过 https://www.envoyproxy.io/docs/envoy/v1.12.2/configuration/http/http_filters/lua_filter,但我找不到任何方法可以做到这一点。无论如何可以通过 Lua 从 Envoy 获取域名?

谢谢

要使用 Lua 从请求中获取域,您可以使用 :host 特殊 header。但是,要按域路由,您可能需要在 RDS 中使用虚拟主机,您可以在其中指定一组对应于一组域的路由,Envoy 将根据域处理流量分区。

https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-virtualhost

对我来说 :host header 没用。

但根据 Derek

列出的页面中的评论,我使用 :authority header 很有效

Internally, Envoy always uses the HTTP/2 :authority header to represent the HTTP/1 Host header. Thus, if attempting to match on Host, match on :authority instead.