How to load balance webapplication with /contextroot


#1

I have a webapplication which is accessed as http://host:port/app.
I have 3 instances of this webapp:
http:// host:8080/app
http:// host:9080/app
http:// host:10080/app

Now I want to setup haproxy infront of it to load balance.
To start with I have install everything ha proxy and the 3 apps on the same host.
This is what I currently have in my haproxy setup which throws 503 Service unavailable error:
frontend webapp1
bind 172.22.178.175:80
default_backend webapp1-servers

backend webapp1-servers
balance source
hash-type consistent
mode http
server webserver1 172.22.178.175:8080
server webserver2 172.22.178.175:9080
server webserver3 172.22.178.175:10080

I tried accessing 172.22.178.175:80/app; 172.22.178.175; 172.22.178.175/app but same message - 503 Service Unavailable.

What am I missing? I am new user to HAProxy.

Regards,
Kunal


#2

Your app must be configured to listen on a particular virtual host.
You may confirm it works when running

curl -v -H "Host: host" 172.22.178.175:80/app

Of course, replace host with your real app name.

Also enabling HAProxy health check may help a bit to troubleshoot and understand where the error may be.