HAProxy community

Proxy return 503 Service Unavailable. BUT! Disable health check its Working!

Hi all,

Need help here.

Currently I’m using HAProxy version 1.5.18, as load balancing for my two server, and each server there are three tomcat, Tomcat1(version 8), Tomcat2(version 6), and Tomcat3(version 8)

All these while this set of configuration are working fine, and until recently, tomcat2 are unable to route, whenever we access, it will return 503 error. After we comment out the option httpchk GET , the site will back to normal.

When I tried to curl for extra information, I found that the only different was the location, whereby tomcat1 and tomcat3 will return the /path , while tomcat2 will return full path including IP, but I’m not sure whether this was the root cause as before this the cofiguration was working fine.

Here are my cfg file.

Global settings

#---------------------------------------------------------------------
global
log 127.0.0.1 local0
log /dev/log local0 info
log /dev/log local0 notice
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
timeout http-request 10000
timeout connect 5000
timeout client 20000
timeout server 20000
timeout http-keep-alive 5000
timeout check 10000

#---------------------------------------------------------------------
frontend http
bind *:80
option httplog
log global
acl is_root path -i /
acl is_domain hdr(host) -i test.abc123.com.my
redirect code 301 location /terminal if is_domain is_root

acl url_tacs path_beg /tacs
use_backend web if url_tacs
default_backend web

acl url_terminal path_beg /terminal
use_backend web1 if url_terminal
default_backend web1

#---------------------------------------------------------------------

round robin balancing between the various backends

#---------------------------------------------------------------------
backend web
mode http
balance roundrobin
option forwardfor
option httpchk GET /tacs/login
http-check expect status 200

cookie JSESSIONID prefix nocache
server  app1 172.222.111.3:8080 cookie app1 check inter 2000 rise 2 fall 2
server  app2 172.222.111.4:8080 cookie app2 check inter 2000 rise 2 fall 2

backend web1
mode http
balance source
option forwardfor
option httpchk GET /terminal/public/internet/index.jsp
http-check expect status 200

cookie JSESSIONID prefix nocache
server  app1 172.222.111.3:9067 cookie app1 check inter 2000 rise 2 fall 2
server  app2 172.222.111.4:9067 cookie app2 check inter 2000 rise 2 fall 2

__________________________________*******************

Curl Tomcat2 Result
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Location: http://172.222.111.4:9067/terminal/
Transfer-Encoding: chunked
Date: Wed, 29 May 2019 03:45:40 GMT

Curl Tomcat1 Result
HTTP/1.1 302
Location: /tacs/
Transfer-Encoding: chunked
Date: Wed, 29 May 2019 03:49:51 GMT

Thanks in advance for your help :slight_smile:

I don’t know how any of your Tomcat backends can work then, you configured the health check to only consider a 200 response a success:

http-check expect status 200

Yet all your backends return a 302 response, so all of them should be down.

Please review haproxy logs.