I tried HAPROXY for my WEBAPP (Hosted on tomcat) -reason for using HAPROXY is that it also supports WEBSOCKETS and my current project uses websockets for server push.
As first step, I tested it with bare bone web application -wow, it’s just so easy, without any hiccups it was up and working in ~30 minutes. I used Linux box as no distribution for windows is available (One can use cygwin) -My previous poston same.
- Download HAPROXY , I used version haproxy-1.4.24.
- Untar it tar -xvf haproxy-1.4.24.tar.gz.
- Build HAPROXY, command “make TARGET=linux26″ This is for centos58, Linux kernel 2.6. 26 in “TARGET=linux26″ indicates kernel for linux, if its 2.4 use TARGET=linux24″. As a side note, to know the kernel use uname -a on your linux box.
- copy haproxy to /usr/sbin use “cp haproxy /usr/sbin/haproxy”
- Create a config file say /etc/haproxy_chandan.cfg:
- A mentioned on the HAPROXY site, this is the bare minimum configuration needed -Add it to the config file
global daemon maxconn 256 defaults mode http timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend http-in bind *:80 default_backend websockets_support backend websockets_support server ws1 a.b.c.d:8888 maxconn 32 server ws2 a.b.c.d:8080 maxconn 32 listen admin bind *:8080 stats enable
- Start HAPROXY, /usr/sbin/haproxy -f /etc/haproxy_chandan.cfg
- As configured, requests will be handled at port 80 while the admin console for haproxy is 8080
- Access your app from http://ipofmachinewherehaproxyisinstalled:80
- Access haproxy admin console from http://ipofmachinewherehaproxyisinstalled:8080
Thats all. Moving on to configure it for WebSockets and see if it needs additional configuration tweaks or changes -will post.
Reference: HAPROXY up and running in couple of minutes from our JCG partner Chandan Pandey at the Thoughts on Software design and development blog.
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy
Thank you!
We will contact you soon.
Tags
HAPROXY
👁 Photo of Chandan Pandey
Chandan PandeyAugust 8th, 2013Last Updated: August 7th, 2013
Chandan PandeyAugust 8th, 2013Last Updated: August 7th, 2013
0 102 1 minute read

This site uses Akismet to reduce spam. Learn how your comment data is processed.