gpt4 book ai didi

ruby-on-rails - Haproxy(Openshift) 无法检查 Rails 4 根路​​径

转载 作者:数据小太阳 更新时间:2023-10-29 08:08:51 28 4
gpt4 key购买 nike

我正在使用 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.

应用程序根/日志/ruby.log

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

路线.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}

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

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

干杯!

最佳答案

因此,您可以尝试一些方法来解决这个问题,其中一个应该可以解决您的问题。

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

    /li>
  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”(2 毫秒)更改为“20000”(20 秒)。

关于ruby-on-rails - Haproxy(Openshift) 无法检查 Rails 4 根路​​径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23290159/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com