与美洲狮和Nginx的Rails应用程序错误500访问

我有6个容器用微服务创build我自己的应用程序。 在这个项目中,我有一个示例应用程序。 当我访问url( http://localhost:80/ )时,浏览器返回错误消息500,

我们很抱歉,但是出了点问题。 如果您是应用程序所有者,请检查日志以获取更多信息。

列表容器:

 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; } } 

更多细节检查项目

 Docker version 1.8.1 docker-compose version: 1.4.0 

谢谢您的帮助 :)

在你的nginx conf中有一个错误:

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

尝试这个:

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

好吧,我find了帮助@ehoffmann的问题

  1. 作为评论@ ehoffmann我有更改apprails
  2. puma和nginx之间的通信必须通过tcp。 我改变了docker-compose.ymlcommand: foreman start command: bundle exec puma -e development -p 3000

日志: Listening on tcp://0.0.0.0:3000