2017-05-21 70 views
0

我將Docker容器部署到Heroku託管。容器包含nginx和靜態文件,由webpack在包含構建階段創建。 根目錄是/數據/萬維網將以index.html,style.css中,style.css.map,bundle.js,vendor.bundle.js和目錄資產(圖像/等)Heroku + docker + nginx每個請求返回500

我的nginx CONF:

worker_processes auto; 

events { 
    use epoll; 
    multi_accept on; 
} 

http { 
    access_log /dev/stdout; 
    error_log /dev/stdout info; 
    server { 
     include listen.conf; 

     types{ 
      text/javascript js; 
      text/css   css; 
      image/jpeg  jpg; 
      image/png   png; 
     } 
     default_type text/html; 

     root /data/www; 
     index /index.html; 
     location/{ 
      try_files $uri $uri/ /index.html; 
     } 
    } 
} 

它本地工作,但是當我把圖像的Heroku:

docker build -t registry.heroku.com/tp-frontend-kv/web . 
docker push registry.heroku.com/tp-frontend-kv/web 

每個請求返回500,在Heroku nginx的日誌:

2017-05-21T10:31:09.254234+00:00 heroku[router]: at=info method=GET path="/" host=tp-frontend-kv.herokuapp.com request_id=63388b37-4b9b-432b-88c2-8ae393e2708d fwd="178.22.54.74" dyno=web.1 connect=1ms service=1ms status=500 bytes=355 protocol=https 

2017-05-21T10:31:09.256223+00:00 app[web.1]: 2017/05/21 10:31:09 [error] 14#14: *4 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 10.84.188.241, server: , request: "GET/HTTP/1.1", host: "tp-frontend-kv.herokuapp.com", referrer: "https://dashboard.heroku.com/" 

2017-05-21T10:31:09.256368+00:00 app[web.1]: 10.84.188.241 - - [21/May/2017:10:31:09 +0000] "GET/HTTP/1.1" 500 193 "https://dashboard.heroku.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0" 

2017-05-21T10:31:14.935539+00:00 app[web.1]: 2017/05/21 10:31:14 [error] 13#13: *5 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 10.84.188.241, server: , request: "GET /index.html HTTP/1.1", host: "tp-frontend-kv.herokuapp.com" 

2017-05-21T10:31:14.935653+00:00 app[web.1]: 10.84.188.241 - - [21/May/2017:10:31:14 +0000] "GET /index.html HTTP/1.1" 500 193 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0" 

2017-05-21T10:31:14.934805+00:00 heroku[router]: at=info method=GET path="/index.html" host=tp-frontend-kv.herokuapp.com request_id=c7a3943b-3714-4745-8758-37002e735d6e fwd="178.22.54.74" dyno=web.1 connect=0ms service=2ms status=500 bytes=355 protocol=https 

可能是什麼問題?

PS dockerfile及其他:github

回答

0

部署之前,保持你的日誌眼睛運行(Heroku的CLI所需):

$ heroku logs --app <your-app> -t 

您可能會看到這是造成500 Nginx上啓動錯誤反應,例如,如果它試圖綁定到端口80(默認),你會看到:

nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) 

留意這些錯誤,它應該提供這樣我的洞察力。