首页 > 解决方案 > 为什么用“不权威”响应我的 heroku 托管容器应用程序

问题描述

我尝试在Heroku中将我的简单 Web-App作为 Docker Container运行。在本地构建和运行容器时一切正常。

但是在访问生成的端点https://html5-landingpage-buddah.herokuapp.com/ Heroku 响应 HTTP 400 错误请求和消息“非权威”

Heroku 中的日志没有多大帮助:

2020-09-19T14:45:45.269487+00:00 heroku[router]: at=info method=GET path="/" host=html5-landingpage-buddah.herokuapp.com request_id=5f07ea7e-d925-4fbe-b7ba-29387a3284cc fwd="XX.XX.XX.XXX" dyno=web.1 connect=1ms service=1ms status=400 bytes=212 protocol=https

我对该错误进行了研究,但没有发现任何有用的信息。同样在 Heroku 中重新创建应用程序,重命名 URL 并将应用程序移动到另一个区域也没有帮助。


这是从重启到 Web 应用程序上第一个请求的日志:

2021-06-15T17:11:36.977277+00:00 heroku[web.1]: Starting process with command `./app`
2021-06-15T17:11:39.852345+00:00 app[web.1]: [main] INFO de.clique.westwood.example.html5.landingpage.buddah.App - Server started on port 54225
2021-06-15T17:11:39.852374+00:00 app[web.1]: [main] INFO de.clique.westwood.example.html5.landingpage.buddah.App - Serving albums from ./static/album
2021-06-15T17:11:41.363857+00:00 heroku[web.1]: State changed from starting to up
2021-06-15T17:11:48.162254+00:00 heroku[router]: at=info method=GET path="/" host=html5-landingpage-buddah.herokuapp.com request_id=85c642cb-a48d-41ac-89e1-7a520749e9bc fwd="94.31.82.142" dyno=web.1 connect=1ms service=4ms status=421 bytes=219 protocol=https
2021-06-15T17:11:48.275223+00:00 heroku[router]: at=info method=GET path="/" host=html5-landingpage-buddah.herokuapp.com request_id=406e9e77-f40e-47b9-a33b-af0af5b8f171 fwd="94.31.82.142" dyno=web.1 connect=1ms service=3ms status=421 bytes=219 protocol=https
2021-06-15T17:11:48.520876+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=html5-landingpage-buddah.herokuapp.com request_id=d3782734-765c-45f1-98a8-04e2098e7267 fwd="94.31.82.142" dyno=web.1 connect=1ms service=4ms status=421 bytes=219 protocol=https
2021-06-15T17:11:48.906097+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=html5-landingpage-buddah.herokuapp.com request_id=79e4404f-e505-4c16-9778-9f72882d74be fwd="94.31.82.142" dyno=web.1 connect=1ms service=4ms status=421 bytes=219 protocol=https

标签: dockerkotlinherokugraalvmhttp4k

解决方案


该错误Not Authoritative仅意味着 Heroku 无法将流量从所述域名重定向到您的应用程序。

根据Heroku的说法,

Web 进程必须侦听$PORT由 Heroku 设置的 HTTP 流量。EXPOSEinDockerfile不被尊重,但可以用于本地测试。仅支持 HTTP 请求。

您将需要更换您的EXPOSEENTRYPOINT

CMD [ "sh", "-c", "java -jar ./app --bind 0.0.0.0:$PORT" ]

推荐阅读