Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haproxy(Openshift) fails to check Rails 4 root path

I'm using Openshift, Haproxy, Ruby on Rails with Postgresql as backend. I have deployed everything successfully but Haproxy fails to send a HTTP request to the root path of my rails app.

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}

I have deleted the index.html in my public folder (Rails). But, when I add the index.html file to the public folder again everything works and I can access my app under: app_name-appdomain.rhcloud.com/products Which is not perfect, because I want access it without adding /products to the URL.

Thank you for any help! Please let me know if you need any further details on the setup

Cheers!

like image 382
user3572412 Avatar asked Dec 06 '25 14:12

user3572412


1 Answers

SO there are few things you can try to get around this, one of them should solve your problem.

  1. OPTION A: try changing the line option httpchk / to option httpchk GET / If this does not work, make sure you have index.html in your webroot. If you do not prefer this approach or want to point to some other html file (which exists in web root), you can modify it to option httpchk some-other-file.html

  2. OPTION B: simply comment this line, but it would affect haproxy health check.

  3. OPTION C: modify the line to

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

where www is your app link, like, XXX-yyy.rhcloud.com

4.An additional observation, haproxy might fail to check Rails path, as the time-out in the last line of haproxy.cfg seems pretty less. Try changing "200" (2ms) to "20000" (20s).

like image 138
Devesh Chanchlani Avatar answered Dec 08 '25 07:12

Devesh Chanchlani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!