Jun 6, 2011

How To Install HAProxy on Ubuntu 11.04

Happy Monday everyone! I have a pretty good one to share with your today. Over the weekend I stood up an open source load balancer running on Ubuntu Linux and running a free tool called HAProxy. I was originally going to use another load balancing platform called Pound that also does SSL offload, but I decided against it because it would require me changing the way my company’s firewall is configured to ensure that the sites that need to be secured, stayed secured.

I decided to go with HAProxy not just because it is simple in that it can load balance anything, including SSL encrypted sites, but because it doesn’t natively do SSL offload on its own, and lets the web servers handle that. With HAProxy I was able to stand it up in our existing environment without having to change a damn thing on the firewall.

So why the write up on how to install it? I mean, it’s available in the repositories right? Yes it is, but after installing it there are a couple of things you need to do to make sure it starts up when you reboot, especially on Ubuntu 11.04.

haproxySo here it is, how to install HAProxy:

  • Run sudo apt-get update
  • Run sudo apt-get install haproxy
  • After the install, run sudo nano /etc/default/haproxy and change ENABLED=0 to ENABLED=1 and save it

Normally, you can stop here, but for some reason in Ubuntu the /etc/init.d/haproxy script tries to start before networking and fails. To fix that run the following:

  • sudo update-rc.d -f haproxy remove
  • sudo update-rc.d -f networking remove
  • sudo update-rc.d haproxy start 37 2 3 4 5 . stop 20 0 1 6 .
  • sudo update-rc.d networking start 34 2 3 4 5 .

What that does is changes the order of the startup scripts so that Networking has a chance to start before HAProxy. After that you can reboot all you want and HAProxy will start right back up.

I am going to try to find time to write more about my HAProxy setup sometime this week (Maybe tomorrow). It’s pretty cool, and it is allowing me to load balance four webservers each with a mix of SSL HTTPS and standard port 80 HTTP traffic.

Via [Ubuntu Bugs]

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | stopping spam