【问题标题】:Haproxy(Openshift) fails to check Rails 4 root pathHaproxy(Openshift) 无法检查 Rails 4 根路​​径
【发布时间】:2014-06-10 23:50:19
【问题描述】:

我使用 Openshift、Haproxy、Ruby on Rails 和 Postgresql 作为后端。我已成功部署所有内容,但 Haproxy 无法将 HTTP 请求发送到我的 rails 应用程序的根路径。

app-root/logs/haproxy.log

[ALERT] 114/053517 (469622) : proxy 'express' has no server available!    
[WARNING] server express/local-gear is DOWN, reason: Layer7 wrong status, code: 404

app-root/logs/haproxy_ctld.log

ERROR -- : Could not connect to the application.  Check if the application is stopped.

app-root/logs/ruby.log

"OPTIONS /products HTTP/1.0" 404 1351 "-" "-"

routes.rb

  root :to => 'products#index'

haproxy.cfg

global  
   maxconn 4096  
   stats socket /var/lib/{ID}/haproxy//run/stats level admin

defaults  
   log   global  
   mode   http  
   option   httplog  
   option   dontlognull
   option http-server-close  
   retries   3  
   option redispatch  
   maxconn   128
   timeout http-request   10s
   timeout queue 1m
   timeout connect 10s
   timeout client 1m
   timeout server 1m
   timeout http-keep-alive 10s
   timeout check 10s

listen stats xxx.xxx.xxx.131:8080
  mode http
  stats enable
  stats uri /

listen express xxx.xxx.xxx.130:8080
  cookie GEAR insert indirect nocache
  option httpchk /

  balance leastconn
  server local-gear xxx.xxx.xxx.129:8080 check fall 2 rise 3 inter 200 cookie local-{APP_ID}

我已删除公用文件夹 (Rails) 中的 index.html。但是,当我再次将 index.html 文件添加到公用文件夹时,一切正常,我可以在以下位置访问我的应用程序:app_name-appdomain.rhcloud.com/products 这并不完美,因为我想在不将 /products 添加到 URL 的情况下访问它。

感谢您的帮助! 如果您需要有关设置的更多详细信息,请告诉我

干杯!

【问题讨论】:

  • 我也试过:选项 httpchk /products
  • so.. 你找到解决方案了吗?
  • 我在使用 nodejs 应用时遇到了同样的问题。
  • 你还有同样的问题吗?你修好了吗?
  • 很抱歉回答得太晚了,但我无法解决问题。

标签: ruby-on-rails ruby openshift haproxy


【解决方案1】:

因此,您可以尝试解决一些问题,其中之一应该可以解决您的问题。

  1. 选项 A:尝试将行 option httpchk / 更改为 option httpchk GET / 如果这不起作用,请确保您的 webroot 中有 index.html。如果您不喜欢这种方法或想指向其他一些 html 文件(存在于 web 根目录中),您可以将其修改为 option httpchk some-other-file.html

  2. 选项 B:简单地评论这一行,但它会影响 haproxy 健康检查。

  3. 选项 C:将行修改为

option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www

www 是您的应用链接,例如 XXX-yyy.rhcloud.com

4.另外观察,haproxy 可能无法检查 Rails 路径,因为 haproxy.cfg 最后一行的超时似乎要少得多。尝试将“200”(2ms)更改为“20000”(20s)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    • 2016-09-11
    • 1970-01-01
    • 2011-04-13
    相关资源
    最近更新 更多