# How to load balance webapplication with /contextroot

**URL:** <https://discourse.haproxy.org/t/how-to-load-balance-webapplication-with-contextroot/206>\
**Category:** Help!\
**Created:** [April 8, 2016, 9:15pm UTC](https://discourse.haproxy.org/t/how-to-load-balance-webapplication-with-contextroot/206 "2016-04-08T21:15:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kunalgourav](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@kunalgourav](https://discourse.haproxy.org/u/kunalgourav)\
**Post date:** [April 8, 2016, 9:15pm UTC](https://discourse.haproxy.org/t/how-to-load-balance-webapplication-with-contextroot/206/1 "2016-04-08T21:15:40Z")

</div>

I have a webapplication which is accessed as [http://host](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

---

<div class="post-metadata">

**Author:** ![Baptiste](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Baptiste](https://discourse.haproxy.org/u/Baptiste)\
**Post date:** [April 9, 2016, 8:43am UTC](https://discourse.haproxy.org/t/how-to-load-balance-webapplication-with-contextroot/206/2 "2016-04-09T08:43:29Z")

</div>

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.
