1.2.2.23.5. 配置大小写规范化
在某些环境中,在授权策略中对路径进行比较时不区分大小写可能很有用。例如,把 https://myurl/get 视为与 https://myurl/GeT 一样。在这些情况下,您可以使用如下所示的 EnvoyFilter。此过滤器将更改用于比较的路径以及应用程序显示的路径。在本例中,istio-system 是 Service Mesh control plane 项目的名称。
将 EnvoyFilter 保存到文件中并运行以下命令:
$ oc create -f <myEnvoyFilterFile>
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: ingress-case-insensitive
namespace: istio-system
spec:
configPatches:
- applyTo: HTTP_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
name: "envoy.filters.network.http_connection_manager"
subFilter:
name: "envoy.filters.http.router"
patch:
operation: INSERT_BEFORE
value:
name: envoy.lua
typed_config:
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
inlineCode: |
function envoy_on_request(request_handle)
local path = request_handle:headers():get(":path")
request_handle:headers():replace(":path", string.lower(path))
end