【发布时间】:2020-12-18 01:59:13
【问题描述】:
我是 Kong 的新手,所以请耐心等待:) 我在 Windows 服务器上以 http://supermarket.xxxx.com:5000 身份托管我的 API
在 Ubuntu 机器上添加如下服务(http://supermarket.xxxx.com 添加到 hosts 文件中)
curl -i -X POST
--url http://localhost:8001/services/
--data 'name=SupermarketService'
--data 'url=http://supermarket.xxx.com:5000'
HTTP/1.1 201 创建 日期:格林威治标准时间 2020 年 12 月 17 日星期四 07:11:50 内容类型:应用程序/json;字符集=utf-8 连接:保持活动 访问控制允许来源:* 服务器:kong/2.1.3 内容长度:379 X-Kong-Admin-Latency:204
2 添加路线
curl -i -X POST
--url http://localhost:8001/services/SupermarketService/routes
--data 'hosts[]=supermarket.xxx.com'
--data 'paths[]=/api/categories'
--data 'strip_path=false'
--data 'methods[]=GET'
HTTP/1.1 201 创建 日期:格林威治标准时间 2020 年 12 月 17 日星期四 09:01:17 内容类型:应用程序/json;字符集=utf-8 连接:保持活动 访问控制允许来源:* 服务器:kong/2.1.3 内容长度:463 X-Kong-Admin-Latency: 11
在 Ubuntu 机器上测试设置
curl -i -X GET
--url http://localhost:8000/api/categories
--header 'Host: supermarket.xxx.com'
HTTP/1.1 200 正常 内容类型:应用程序/json;字符集=utf-8 传输编码:分块 连接:保持活动 服务器:Microsoft-IIS/8.5 严格的传输安全性:max-age=31536000;包括子域 X-Content-Type-Options: nosniff X 框架选项:SAMEORIGIN X-UA 兼容:IE=Edge,chrome=1 X-Xss-保护:1;模式=块 内容安全策略:default-src https:数据:'unsafe-inline''unsafe-eval''self'; connect-src 'self' 数据:*; 日期:格林威治标准时间 2020 年 12 月 17 日星期四 23:10:21 X-Kong-上游延迟:1586 X-Kong-代理延迟:2 来源:kong/2.1.3
[{"id":100,"name":"Fruits and Vegetables"},{"id":101,"name":"Dairy"}]
当我尝试使用网络浏览器访问另一个框中的相同 API 时 http://192.168.44.67:8000/api/categories //其中 192.168.44.67 是我的 Ubuntu 机器的 IP 地址 我明白了 {"message":"没有与这些值匹配的路由"}
请告诉我出了什么问题。
【问题讨论】:
标签: proxy forwarding kong