【发布时间】:2017-12-28 10:05:07
【问题描述】:
我有 kong 在我的本地 linux 机器上的 8000 和 8001 端口上运行,我也有 kong,它在我的 docker 容器中的一个 5000 和 5001 端口上运行。
我的应用程序在 Tomcat 服务器上的另一个容器上运行,端口为 8811(端口从 8811 到 8080)
我已经使用以下 API 配置配置了我的 kong 容器,
curl -i -X POST \
--url http://localhost:5001/apis/ \
--data 'name=sample' \
--data 'uris=/samplewar' \
--data 'upstream_url=http://localhost:8811/sample/hello'
和我的 linux 机器 kong 以及以下 API 配置,
curl -i -X POST \
--url http://localhost:8001/apis/ \
--data 'name=sample' \
--data 'uris=/samplewar' \
--data 'upstream_url=http://localhost:8811/sample/hello'
当我通过 curl 访问我的示例 API 时,我看到来自 Kong 容器的以下错误响应,
curl -i -X GET --url http://localhost:5000/samplewar
HTTP/1.1 502 Bad Gateway
Date: Thu, 28 Dec 2017 08:25:26 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: kong/0.11.2
An invalid response was received from the upstream server
如果我尝试在我的 linux 机器中调用相同的 API,我会看到以下成功响应。
curl -i -X GET --url http://localhost:8000/samplewar
HTTP/1.1 200 OK
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 311
Connection: keep-alive
Server: Apache-Coyote/1.1
Date: Thu, 28 Dec 2017 08:25:33 GMT
X-Kong-Upstream-Latency: 2
X-Kong-Proxy-Latency: 0
Via: kong/0.11.2
<html>
<head>
<title>Sample Application Servlet Page</title>
</head>
<body bgcolor=white>
<table border="0">
<tr>
<td>
<img src="images/tomcat.gif">
</td>
<td>
<h1>Sample Application Servlet</h1>
This is the output of a servlet that is part of
the Hello, World application.
</td>
</tr>
</table>
</body>
</html>
这里有什么问题?为什么我的 Kong 容器没有给出正确的响应?
【问题讨论】:
-
请格式化您的代码,将其更改为Minimal, Complete, and Verifiable Example。
-
谢谢,我把代码格式化了。
标签: tomcat docker curl containers kong