目标:
转到https://secret-sands-1568.herokuapp.com/myFile.html将显示Nginx发送的client/myFile.html
内容。
据我所知,Heroku dynos通常用于Nodejs / Ruby /其他应用程序,但可以通过修改buildrack将它们转换为任何东西。
tmp
的文件夹,文件为app-initialized
。client
的文件夹,文件为myFile.html
。在config/nginx.conf.erb
中,我通过
location /
location / {
root client;
index index.html index.htm;
}
Procfile
,内容为:web: bin/start-nginx
。我输入了heroku config:set BUILDPACK_URL=https://github.com/ryandotsmith/nginx-buildpack.git
。
我输入了git init
heroku create
git push heroku master
heroku ps:scale web=1
。
然而,当我去https://secret-sands-1568.herokuapp.com/myFile.html时,什么都没有。 Heroku日志说:
2015-05-19T07:13:32.990254+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:33.995458+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:34.998228+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:36.000823+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:37.005955+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:38.008548+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:39.011184+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:40.013788+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:41.016516+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:42.019372+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:43.023551+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:44.029985+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:45.035183+00:00 app[web.1]: buildpack=nginx at=app-initialization
2015-05-19T07:13:45.910618+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-05-19T07:13:45.910618+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-05-19T07:13:46.732519+00:00 heroku[web.1]: State changed from starting to crashed
2015-05-19T07:13:46.718745+00:00 heroku[web.1]: Process exited with status 137
2015-05-19T07:17:12.890713+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=obscure-caverns-1927.herokuapp.com request_id=6d15e849-ce45-41bc-9bad-60d9eb0454ef fwd="24.200.222.98" dyno= connect= service= status=503 bytes=
2015-05-19T07:17:13.039723+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=obscure-caverns-1927.herokuapp.com request_id=7aeecc36-05b5-4799-bf0a-6ba97b2a6190 fwd="24.200.222.98" dyno= connect= service= status=503 bytes=
2015-05-19T07:17:18.350029+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/myFile" host=obscure-caverns-1927.herokuapp.com request_id=cb77356f-ddf3-4795-b56d-fa9cde5d134a fwd="24.200.222.98" dyno= connect= service= status=503 bytes=
2015-05-19T07:17:18.471762+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=obscure-caverns-1927.herokuapp.com request_id=64a89596-b287-4b89-a3ce-ed750e4fb1c1 fwd="24.200.222.98" dyno= connect= service= status=503 bytes=
2015-05-19T07:17:22.250495+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=obscure-caverns-1927.herokuapp.com request_id=4ccda4e8-1532-49dc-8658-e67312ef333d fwd="24.200.222.98" dyno= connect= service= status=503 bytes=
2015-05-19T07:17:22.125124+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/myFile.html" host=obscure-caverns-1927.herokuapp.com request_id=33cdee81-2dda-44cb-acf7-2dc5b4156ef2 fwd="24.200.222.98" dyno= connect= service= status=503 bytes=
我做错了什么?我的目标是拥有一个值得静态文件的独立Nginx服务器。
答案 0 :(得分:1)
编辑:对于专门提供静态文件的服务,您无需进行所有这些工作。有一个 buildpack heroku-community/static,它比 nginx 的要简单得多,而且说明迎合了静态站点。我刚刚让我的 Angular 网站使用它。
我知道这可能不会帮助原来的提问者,但它可能会帮助找到这个的其他人。
注意:这只是部分答案。我仍在寻找更多的调试。但是我通过执行以下操作设法让我的从超时到提供所有 404 页面。
另外请注意,我没有使用来自 github 的一个。我正在使用 https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-nginx,通过 HumanA.cpp:15:91: error: binding reference member '_weapon' to stack allocated
parameter 'weapon' [-Werror,-Wdangling-field]
...name, Weapon weapon) : _name(ft::strcapitalize(name)), _weapon(weapon)
^~~~~~
./HumanA.hpp:35:12: note: reference member declared here
Weapon &_weapon;
^
1 error generated.
简介:
heroku buildpacks:add heroku-community/nginx
这应该提供静态文件,而不是尝试路由到另一个侦听器。
到目前为止,我一直收到如下 nginx 错误:web: bin/start-nginx-solo
(这些来自 open() "/dist/index.html" failed (2: No such file or directory)
)。构建成功,但它无法找到任何文件。仍在努力解决这个问题,但至少它不再因启动超时而崩溃。