KongIngress 对象中的 strip_path 和preserve_host 属性

问题描述 投票:0回答:1

在 k8s 集群中,我们有一个 ASP.NET Core 6 MVC Web 应用程序。如果我使用 NGINX 入口类配置入口控制器 -> 使用请求主机和路径前缀 / ,目标服务集群 IP 端口 443 都可以正常工作。

如果我想使用 Kong 入口类 -> 前缀 /onename,目标服务集群 IP 端口 443,剥离路径 true 并将主机保留为 false。我明白了

{
    "message": "An invalid response was received from the upstream server"
}

ASP.NET Core MVC Web 应用程序具有基本路径

/

如何使用 Kong 入口类配置入口控制器?

我想导航,例如: https://res0ingresskong.resources.root.gc.local/onename

路由到集群上我的 ASP.NET Core MVC 应用程序的 /

asp.net-core-mvc .net-6.0 kong ingress-controller
1个回答
0
投票

我想导航,例如:https://res0ingresskong.resources.root.gc.local/onename

前缀 /onename,目标服务集群 IP 端口 443,剥离路径 true 并将主机保留为 false。

在您当前的配置下,Kong 将接受路径

/onename
的请求,剥离它,并将
/
请求发送到您的 .NET 应用程序。
这是默认的 Kong 配置,因为通常使用 API 网关来屏蔽上游路径。
如果希望Kong的路径和upstream的路径相同,请将strip_path设置为
false

来自文档的参考:

strip_path
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.

参考

© www.soinside.com 2019 - 2024. All rights reserved.