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!
SO there are few things you can try to get around this, one of them should solve your problem.
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
OPTION B: simply comment this line, but it would affect haproxy health check.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With