我有一个简单的网站建设使用狂欢集装箱在码头形象。我试图在云运行中运行这个映像。不幸的是,当我访问站点的URL时,我在浏览器和日志行中看到了502
2020/10/30 17:27:07 http: proxy error: dial tcp 0.0.0.0:16166: connect: connection refused
我假设它与端口有关,但是我尝试将端口映射到9898,我仍然在日志行中看到了一个随机端口号。目前,按照GCP文档的建议,我在我的狂欢应用程序中将端口设置为${PORT}。
我应该指出,我可以在本地部署容器,而不存在任何问题。
Dockerfile:
FROM golang:1.15 AS build
ENV CGO_ENABLED 0
ADD . /go/src/app
# Install revel framework
RUN go get -u github.com/revel/revel
RUN go get -u github.com/revel/cmd/revel
# Run revel app
EXPOSE ${PORT}
ENTRYPOINT revel run -a /go/src/app -p ${PORT} -m dev欢庆app.conf片段:
# The IP address on which to listen.
http.addr = 0.0.0.0
# The port on which to listen.
http.port = ${PORT}更新:--建议使用硬编码端口8080,并查看它是否有效。我还能看到502号。我尝试在本地再次运行它,它看起来像是在一个端口上设置,然后在另一个端口上作为反向代理进行侦听。所以,除非我认为这可能是个有趣的问题,而不是云运行问题
docker run --publish 8080:8080 app
Revel executing: run a Revel application
Changed detected, recompiling
Parsing packages, (may require download if not cached)... Completed
INFO 02:34:24 app run.go:34: Running revel server
INFO 02:34:24 app plugin.go:9: Go to /@tests to run the tests.
Revel engine is listening on.. 0.0.0.0:44795
Time to recompile 8.0340966s
Revel proxy is listening, point your browser to : 8080注意最后一行Revel proxy is listening, point your browser to : 8080,但也注意到Revel engine is listening on.. 0.0.0.0:44795
发布于 2020-11-01 17:43:07
因此,经过进一步的调查和讨论,似乎当您通过revel run运行狂欢应用程序时,将在一个随机端口上设置一个代理,而该连接正是失败的原因。此外,通过revel run运行的最大好处是热交换部署的代码,这在部署的上下文中是不必要的。因此,这里的解决方案是通过revel build构建应用程序,并以这种方式运行该应用程序,以便只使用应用程序端口进行连接。
https://stackoverflow.com/questions/64613763
复制相似问题