孔 {"message":"no Route matched with those values"}

标签 kong

我试过https://docs.konghq.com/getting-started-guide/2.1.x/expose-services/ 我也有本地服务器:kong/2.2.1 我可以同时注册服务和路由器,但是当我调用 kong 重定向它时会出现以下错误。

服务注册:

{
    "host": "localhost",
    "id": "2546864e-6ac0-41e5-b39f-b05310ac53f8",
    "protocol": "http",
    "read_timeout": 60000,
    "tls_verify_depth": null,
    "port": 16001,
    "updated_at": 1607946666,
    "ca_certificates": null,
    "created_at": 1607946666,
    "connect_timeout": 60000,
    "write_timeout": 60000,
    "name": "newkong",
    "retries": 5,
    "path": null,
    "tls_verify": null,
    "tags": null,
    "client_certificate": null
}

路由器注册:

{
    "id": "726eec9e-b179-4731-937f-e85a10101987",
    "tags": null,
    "paths": [
        "/customer"
    ],
    "destinations": null,
    "headers": null,
    "protocols": [
        "http",
        "https"
    ],
    "strip_path": true,
    "created_at": 1607946800,
    "request_buffering": true,
    "hosts": null,
    "name": "newkong-routing",
    "updated_at": 1608446942,
    "snis": null,
    "preserve_host": false,
    "regex_priority": 0,
    "methods": null,
    "sources": null,
    "response_buffering": true,
    "https_redirect_status_code": 426,
    "path_handling": "v0",
    "service": {
        "id": "2546864e-6ac0-41e5-b39f-b05310ac53f8"
    }
}

在 http://localhost:8000/customer/1 上调用 kong

这样它就可以重定向到 http://localhost:16001/customer/1

{"message":"没有与这些值匹配的路由"}

最佳答案

乍一看,这应该可行。除了上游路径将被剥离,因为路由具有 "strip_path": true

{
  "paths": [
    "/customer"
  ],
  "methods": null,
  "hosts": null,
  "snis": null,
  "headers": null,
  "protocols": [
    "http",
    "https"
  ],
  "strip_path": true,
  "created_at": 1607946800,
  "request_buffering": true,
  "name": "newkong-routing",
  "updated_at": 1608446942,
  "preserve_host": false,
  "regex_priority": 0,
  "sources": null,
  "response_buffering": true,
  "https_redirect_status_code": 426,
  "path_handling": "v0",
  "id": "726eec9e-b179-4731-937f-e85a10101987",
  "destinations": null,
  "tags": null,
  "service": {
    "id": "2546864e-6ac0-41e5-b39f-b05310ac53f8"
  }
}

因为唯一的路由属性集是“协议(protocol)”和“路径”,所以它应该可以工作。你确定这是正确的吗?

提出请求时:

http://localhost:8000/customer/1

它应该代理:

http://localhost:16001/1

因为匹配的路径元素(/customer)正在被剥离。

关于孔 {"message":"no Route matched with those values"},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65289496/

相关文章:

kubernetes - Kong Ingress Controller - 删除与 Kong 相关的 header

kong - kong API网关的多个请求转换器

microservices - Kong 是否支持 API 聚合

kubernetes - 您好,我正在尝试获取客户端真实 IP 以限制对 kubernetes environemnt 上 pod 的某些访问

javascript - 使用 Kong 的安全 api

authentication - 如何为新 API 自动启用 Kong 身份验证插件?

redis - 如何将redis与kong api网关一起使用

spring-boot - 如何设置 API 网关和微服务之间的 SSL 通信?

kubernetes - Kong 入口 Controller 出现错误 "no Route matched with those values"

postgresql - 如何修复konga_db