# Configure HAProxy for round robin load balancing

**URL:** <https://discourse.haproxy.org/t/configure-haproxy-for-round-robin-load-balancing/507>\
**Category:** Help!\
**Created:** [July 17, 2016, 3:13pm UTC](https://discourse.haproxy.org/t/configure-haproxy-for-round-robin-load-balancing/507 "2016-07-17T15:13:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![3rw1Nr1S0s](https://avatars.discourse-cdn.com/v4/letter/3/fbc32d/32.png) [@3rw1Nr1S0s](https://discourse.haproxy.org/u/3rw1Nr1S0s)\
**Post date:** [July 17, 2016, 3:13pm UTC](https://discourse.haproxy.org/t/configure-haproxy-for-round-robin-load-balancing/507/1 "2016-07-17T15:13:21Z")

</div>

I installed haproxy and apache on same server. I then cloned the server for load balancing. My goal is to have apache handle both http and https requests (ssl passthrough) and have all http requests redirected to https automatically. I choosed round robin as algorithm for load balancing. I configured haproxy to use ports 80 and 443 for binding to virtual the IP (10.10.0.1) and have apache listen on ports 8080 and 4443 for “passed through” requests.

After much googling, I have the following haproxy.cfg setup on both servers:  
-------------------------------------------------------------------------------------------------------------  
\<snip\>

###-Redirect http requests to https-######  
frontend http\_to\_https\_redirect  
 bind 10.10.0.1:80  
 mode http  
 redirect scheme https if !{ ssl\_fc }

frontend https\_frontend  
 bind 10.10.0.1:443  
 mode tcp  
 option tcplog  
 default\_backend https\_backend

backend https\_backend  
 mode tcp  
 balance roundrobin  
 option ssl-hello-chk  
 server ws1 10.10.0.2:4443 check  
 server ws2 10.10.0.3:4443 check

\<snip\>  
-------------------------------------------------------------------------------------------------------------

I used curl and wget to test the above configuration and noted that all connections were directed only to ws1 although roundrobin was specified as algorithm. I would appreciate if someone can share insight on how to make roundrobin work.

Also, is it better (performance wise) if http-to-https redirection is done at apache level rather than at haproxy? If so, how do I configure haproxy so that both http and https connections get forwarded to apache? Thanks.

Kristy

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [July 25, 2016, 12:12pm UTC](https://discourse.haproxy.org/t/configure-haproxy-for-round-robin-load-balancing/507/2 "2016-07-25T12:12:52Z")

</div>

Maybe the backend is down due to a failed health check, we cannot possibly tell.  
Check your haproxy logs to find out more.

http-to-https redirection works very well on haproxy, no need to forward to apache for that.

Please do read the documentation and configure haproxy based on the documentation, not copy and paste everything from random configuration examples on the internet.
