2015-11-09 21 views
0

我有6個容器來創建我自己的應用程序與微服務。在這project我有一個示例應用程序。當我訪問網址(http://localhost:80/)時,瀏覽器返回錯誤消息:與美洲獅和nginx的rails應用程序錯誤500訪問

return我們很抱歉,但出錯了。如果您是 應用程序所有者,請檢查日誌以獲取更多信息。

列表容器:

CONTAINER ID  IMAGE    COMMAND     CREATED    STATUS       PORTS      NAMES 
69ee0ef25faa  falcon_nginx  "/usr/sbin/nginx"  59 seconds ago  Up 10 seconds     0.0.0.0:80->80/tcp   falcon_nginx_1 
411e41943a35  falcon_web   "foreman start"   About a minute ago Up 11 seconds     0.0.0.0:3000->3000/tcp  falcon_web_1 
95de66fe7aae  redis    "/entrypoint.sh redis" About a minute ago Up 12 seconds     6379/tcp     falcon_redis_1 
7693b7e2d2eb  memcached:latest "/entrypoint.sh memca" About a minute ago Up 12 seconds     0.0.0.0:11211->11211/tcp falcon_memcached_1 
020566c4a77a  mysql:latest  "/entrypoint.sh mysql" About a minute ago Up 12 seconds     0.0.0.0:3306->3306/tcp  falcon_db_1 
7bf8176503f4  busybox    "true"     About a minute ago Exited (0) About a minute ago        mysql_data 

登錄:

web_1  | 14:34:04 web.1 | started with pid 32 
web_1  | 14:34:04 log.1 | started with pid 33 
web_1  | 14:34:04 log.1 | ==> log/puma.stderr.log <== 
web_1  | 14:34:04 log.1 | === puma startup: 2015-11-05 10:39:01 -0300 === 
web_1  | 14:34:04 log.1 | === puma startup: 2015-11-09 14:33:16 +0000 === 
web_1  | 14:34:04 log.1 | 
web_1  | 14:34:04 log.1 | ==> log/development.log <== 
web_1  | 14:34:04 log.1 | 
web_1  | 14:34:04 log.1 | ==> log/puma.stdout.log <== 
web_1  | 14:34:04 log.1 | [17288] - Gracefully shutting down workers... 
web_1  | 14:34:04 log.1 | [17288] === puma shutdown: 2015-11-05 10:39:07 -0300 === 
web_1  | 14:34:04 log.1 | [17288] - Goodbye! 
web_1  | 14:34:04 log.1 | === puma startup: 2015-11-09 14:33:16 +0000 === 
web_1  | 14:34:04 log.1 | [31] * Starting control server on unix:///tmp/puma-status-1447079596225-31 
web_1  | 14:34:04 log.1 | [31] - Gracefully shutting down workers... 
web_1  | 14:34:04 log.1 | [39] Early termination of worker 
web_1  | 14:34:04 log.1 | [43] Early termination of worker 
web_1  | 14:34:04 log.1 | [31] === puma shutdown: 2015-11-09 14:33:24 +0000 === 
web_1  | 14:34:04 log.1 | [31] - Goodbye! 
web_1  | 14:34:05 web.1 | [32] Puma starting in cluster mode... 
web_1  | 14:34:05 web.1 | [32] * Version 2.11.2 (ruby 2.1.5-p273), codename: Intrepid Squirrel 
web_1  | 14:34:05 web.1 | [32] * Min threads: 1, max threads: 16 
web_1  | 14:34:05 web.1 | [32] * Environment: development 
web_1  | 14:34:05 web.1 | [32] * Process workers: 2 
web_1  | 14:34:05 web.1 | [32] * Phased restart available 
web_1  | 14:34:05 web.1 | [32] * Listening on unix:///home/app/tmp/sockets/puma.sock 
web_1  | 14:34:05 web.1 | [32] Use Ctrl-C to stop 
web_1  | 14:34:05 log.1 | === puma startup: 2015-11-09 14:34:05 +0000 === 
web_1  | 14:34:05 log.1 | 
web_1  | 14:34:05 log.1 | ==> log/puma.stderr.log <== 
web_1  | 14:34:05 log.1 | === puma startup: 2015-11-09 14:34:05 +0000 === 
web_1  | 14:34:05 log.1 | 
web_1  | 14:34:05 log.1 | ==> log/puma.stdout.log <== 
web_1  | 14:34:05 log.1 | [32] * Starting control server on unix:///tmp/puma-status-1447079645129-32 
web_1  | 14:34:09 log.1 | [32] - Worker 1 (pid: 44) booted, phase: 0 
web_1  | 14:34:09 log.1 | [32] - Worker 0 (pid: 40) booted, phase: 0 

Nginx的網站:

upstream rails { 
    server web fail_timeout=0; 
} 

server { 
    listen 80; 
    client_max_body_size 2M; 
    server_name localhost; 
    keepalive_timeout 5; 
    root /home/app/public; 
    access_log /var/log/nginx/access.log; 
    error_log /var/log/nginx/error.log; 

    location ~ ^/(assets)/ { 
    gzip_static on; 
    expires  max; 
    add_header Cache-Control public; 
    } 

    location/{ 
    try_files $uri/index.html $uri.html $uri @app; 
    error_page 404    /404.html; 
    error_page 422    /422.html; 
    error_page 500 502 503 504 /500.html; 
    error_page 403    /403.html; 
    } 

    location @rails { 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_redirect off; 
    proxy_pass http://rails; 
    } 

    location = /favicon.ico { 
    expires max; 
    add_header Cache-Control public; 
    } 
} 

有關詳情,請project

Docker version 1.8.1 
docker-compose version: 1.4.0 

感謝您的幫助:)

+0

什麼在nginx的日誌? –

+0

@japed nginx不會返回任何錯誤 – kalelc

+0

這些'log/puma.stderr.log'和'log/puma.stdout.log'它們在上面的日誌中列出,我假設它們在那裏記錄什麼? –

回答

1

。在你的nginx的conf錯誤:

try_files $uri/index.html $uri.html $uri @app; 

試試這個:

try_files $uri/index.html $uri.html $uri @rails; 
+0

是的,完美的。如果看過它,我已經忘記糾正它。也謝謝!! – kalelc

+0

很高興幫助!它解決了這個問題嗎? – ehoffmann

+0

50/50,在你的幫助下看看我的解決方案:) – kalelc

0

玉傢伙,我發現有幫助的問題@ehoffmann

  1. as c omments @ehoffmann我已將app更改爲rails
  2. puma和nginx之間的通信必須通過tcp。我在docker-compose.yml線改變command: foreman startcommand: bundle exec puma -e development -p 3000

登錄:Listening on tcp://0.0.0.0:3000

+0

好吧,如果你想保持套接字通信,你可以讓'foreman start'並用'server unix:/// home替換'server web fail_timeout = 0;'' /app/tmp/sockets/puma.sock;'在nginx.conf的上游部分。 – ehoffmann

+0

@ehoffmann但記住nginx是一個容器和puma其他容器,容器之間的通信是tcp。 – kalelc

+0

是的,但是你的docker-compose.yml中有'volume_from:web'。使用這個配置,你可以直接從你的nginx容器訪問'/ home/app/tmp/sockets/puma.sock'。 – ehoffmann

相關問題