{"id":2369,"date":"2016-08-03T15:20:53","date_gmt":"2016-08-03T19:20:53","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2369"},"modified":"2017-11-24T17:55:07","modified_gmt":"2017-11-24T22:55:07","slug":"install-haproxy-ubuntu-14","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/","title":{"rendered":"How to Install HAProxy on Ubuntu 14"},"content":{"rendered":"<h1>How to Install HAProxy on Ubuntu 14<\/h1>\n<p>HAProxy is a fast, efficient HTTP server and proxy with support for features not included in the typical load balancer. Its inclusion of SSL termination offers the capability for HTTPS without a separate piece of infrastructure to manage secure traffic. HAProxy can also proxy TCP connections, making it ideal for load balancing between more than just HTTP endpoints. Because of its use in services that can&#8217;t afford downtime, HAProxy can restart without dropping connections. It is a great choice for anyone seeking a reliable load balancer or proxy for a variety of back-end services.<\/p>\n<h2>Getting Started<\/h2>\n<p>To complete this guide, you will need the following:<br \/>\n\u2022 1 Node (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>) running a clean install of Ubuntu 14.<br \/>\n\u2022 Root access to the server.<\/p>\n<p>When complete, the server will be running HAProxy, and you can begin integrating other back-end services.<\/p>\n<p><a href=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png\" alt=\"load balancer web server\" width=\"300\" height=\"250\" class=\"aligncenter size-full wp-image-2379\" \/><\/a><\/p>\n<h2>Tutorial<\/h2>\n<p>Start by completely updating your system. This does several things. It updates the package list cache, so future downloads will find the correct files. It also integrates all currently available bugfixes and security patches. Perform this step regularly to keep your system running securely and performing well.<\/p>\n<p><code>apt-get update && apt-get upgrade -y<\/code><\/p>\n<h2>Install HAProxy<\/h2>\n<p>HAProxy is included in Ubuntu&#8217;s package repository. We&#8217;ll next install the official HAProxy package.<\/p>\n<p><code>apt-get install haproxy -y<\/code><\/p>\n<p>HAProxy is a versatile server, and just how it should be configured in your scenario is beyond the scope of this guide. Even so, a few basic principles are helpful to understand how it works. Here is a basic HAProxy configuration to make it listen on a port.<\/p>\n<p><code>nano \/etc\/haproxy\/haproxy.conf<\/code><\/p>\n<p>Here is how you&#8217;d configure an HTTPS endpoint. In this example, we proxy to two back-end servers at 192.168.1.10 and 192.168.1.11. We also enable the stats page, which lets you check the status of traffic to these separate servers.<\/p>\n<p><code class=\"gris\">global<br \/>\n    log         127.0.0.1 local2<br \/>\n    chroot      \/var\/lib\/haproxy<br \/>\n    pidfile     \/var\/run\/haproxy.pid<br \/>\n    maxconn     16384<br \/>\n    user        haproxy<br \/>\n    group       haproxy<br \/>\n    daemon<br \/>\n    # turn on stats unix socket<br \/>\n    stats socket \/var\/run\/haproxy.cmd<\/code><\/p>\n<p><code class=\"gris\">defaults<br \/>\n    mode                    http<br \/>\n    log                     global<br \/>\n    option                  httplog<br \/>\n    option                  dontlognull<br \/>\n    option                  httpclose<br \/>\n    option forwardfor       except 127.0.0.0\/8<br \/>\n    option                  redispatch<br \/>\n    retries                 3<br \/>\n    timeout http-request    10s<br \/>\n    timeout queue           1m<br \/>\n    timeout connect         10s<br \/>\n    timeout client          45s<br \/>\n    timeout server          45s<br \/>\n    timeout check           10s<br \/>\n    maxconn                 16384<\/code><\/p>\n<p><code class=\"gris\">listen stats :9000<br \/>\n    mode http<br \/>\n    stats enable<br \/>\n    stats uri \/haproxy<br \/>\n    stats realm HAProxy\\ Statistics<br \/>\n    stats auth haproxy:password<br \/>\n    stats admin if TRUE<\/code><\/p>\n<p><code class=\"gris\">listen http :80<br \/>\n        balance leastconn<br \/>\n        option http-server-close<br \/>\n        option forwardfor<br \/>\n        server web1 192.168.1.10:80 check inter 3000 rise 2 fall 3<br \/>\n        server web2 192.168.1.11:80 check inter 3000 rise 2 fall 3<\/code><\/p>\n<p><code class=\"gris\">listen https :443<br \/>\n        balance leastconn<br \/>\n        option http-server-close<br \/>\n        option forwardfor<br \/>\n        server web1 192.168.1.10:443 check inter 3000 rise 2 fall 3<br \/>\n        server web2 192.168.1.11:443 check inter 3000 rise 2 fall 3<\/code><\/p>\n<p>With the above configuration in place, traffic from ports 80 and 443 of your HAProxy server is sent to the configured back-end servers. It is necessary to restart Haproxy for this configuration to take effect. We&#8217;ll do that now.<\/p>\n<p><code>service haproxy restart<\/code><\/p>\n<p>To check whether HAProxy is working, let&#8217;s visit the previously-configured stats page on port 9000. For instance, if your IP is 67.215.1.1, visit http:\/\/67.215.1.1:9000 to see HAProxy handling inbound traffic.<\/p>\n<p>HAProxy must now be configured to start on boot. To do so, run this command.<\/p>\n<p><code>sudo update-rc.d haproxy enable<\/code><\/p>\n<p>Hatop is a useful tool to monitor HAProxy statistics from the command line. Install and run it to check out what information it provides.<\/p>\n<p><code>apt-get -y install hatop ; hatop -s \/var\/run\/haproxy.cmd<\/code><\/p>\n<p>If you&#8217;d rather not use the &#8220;-s&#8221; parameter every time you run Hatop, you can modify ~\/.bashrc as shown.<\/p>\n<p><code>echo \"alias hatop='hatop -s \/var\/run\/haproxy.cmd'\" >> ~\/.bashrc<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>You&#8217;ve now succeeded to install HAProxy and configure route traffic to various servers, with a configured SSL certificate. You&#8217;ll next want to integrate it into your own infrastructure by replacing the certificate, and by proxying to your own HTTP or TCP servers. If this guide was helpful to you, kindly share it with others who may also be interested. <\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to Install HAProxy on Ubuntu 14 HAProxy is a fast, efficient HTTP server and proxy with support for features not included in the typical load balancer. Its inclusion of SSL termination offers the capability for HTTPS without a separate piece of infrastructure to manage secure traffic. HAProxy can also proxy TCP connections, making it<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[],"class_list":["post-2369","post","type-post","status-publish","format-standard","hentry","category-ha-clustering"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Install HAProxy on Ubuntu 14 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to install HAProxy on your Ubuntu 14 server. Read now &amp; Enjoy this reliable load balancer!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install HAProxy on Ubuntu 14 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to install HAProxy on your Ubuntu 14 server. Read now &amp; Enjoy this reliable load balancer!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-03T19:20:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-24T22:55:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/\",\"name\":\"How to Install HAProxy on Ubuntu 14 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png\",\"datePublished\":\"2016-08-03T19:20:53+00:00\",\"dateModified\":\"2017-11-24T22:55:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to install HAProxy on your Ubuntu 14 server. Read now & Enjoy this reliable load balancer!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#primaryimage\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png\",\"contentUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install HAProxy on Ubuntu 14\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install HAProxy on Ubuntu 14 - Globo.Tech","description":"This tutorial will show you how to install HAProxy on your Ubuntu 14 server. Read now & Enjoy this reliable load balancer!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/","og_locale":"en_US","og_type":"article","og_title":"How to Install HAProxy on Ubuntu 14 - Globo.Tech","og_description":"This tutorial will show you how to install HAProxy on your Ubuntu 14 server. Read now & Enjoy this reliable load balancer!","og_url":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/","og_site_name":"Globo.Tech","article_published_time":"2016-08-03T19:20:53+00:00","article_modified_time":"2017-11-24T22:55:07+00:00","og_image":[{"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png","type":"","width":"","height":""}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/","url":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/","name":"How to Install HAProxy on Ubuntu 14 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#primaryimage"},"image":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#primaryimage"},"thumbnailUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png","datePublished":"2016-08-03T19:20:53+00:00","dateModified":"2017-11-24T22:55:07+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to install HAProxy on your Ubuntu 14 server. Read now & Enjoy this reliable load balancer!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#primaryimage","url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png","contentUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/08\/Image1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/install-haproxy-ubuntu-14\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to Install HAProxy on Ubuntu 14"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2369"}],"version-history":[{"count":15,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2369\/revisions"}],"predecessor-version":[{"id":3888,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2369\/revisions\/3888"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}