{"id":428,"date":"2012-06-21T12:59:10","date_gmt":"2012-06-21T04:59:10","guid":{"rendered":"http:\/\/rmohan.com\/?p=428"},"modified":"2012-06-21T12:59:26","modified_gmt":"2012-06-21T04:59:26","slug":"apache-mod_proxy-as-load-balancer","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=428","title":{"rendered":"Apache mod_proxy  as  Load Balancer"},"content":{"rendered":"<p style=\"text-align: left;\"><strong>Apache mod_proxy\u00a0 as\u00a0 Load Balancer<\/strong><\/p>\n<p style=\"text-align: left;\">This article presents an example of load balancing using Apache2.<\/p>\n<p>For example take the host 192.168.1.100 as a balancer, this host will install the apache front end acting for all requests and will balance the load on other hosts.<\/p>\n<p>The load is redirected to the host 192.168.1.101,192.168.1.102,192.168.1.103 and 192.168.1.104.<\/p>\n<p>Configuring apache2<\/p>\n<p>First of all we need to install apache server on the host server acting principal<\/p>\n<p>On 192.168.1.100, install Apache2:<\/p>\n<p>yum install httpd httpd-devel<\/p>\n<p>yum intall mod_proxy<\/p>\n<p>grep -i proxy \/etc\/httpd\/conf\/httpd.conf<br \/>\nLoadModule proxy_module modules\/mod_proxy.so<br \/>\nLoadModule proxy_balancer_module modules\/mod_proxy_balancer.so<br \/>\nLoadModule proxy_ftp_module modules\/mod_proxy_ftp.so<br \/>\nLoadModule proxy_http_module modules\/mod_proxy_http.so<br \/>\nLoadModule proxy_connect_module modules\/mod_proxy_connect.s<\/p>\n<p>proxy Settings<\/p>\n<p>On 192.168.1.100, add the \/etc\/httpd\/conf.d\/proxy.conf, this file will contain the nodes that will balance the incoming load.<\/p>\n<p>&lt;Proxy balancer:\/\/mycluster&gt;<br \/>\nBalancerMember http:\/\/192.168.1.101<br \/>\nBalancerMember http:\/\/192.168.1.102<br \/>\nBalancerMember http:\/\/192.168.1.103<br \/>\nBalancerMember http:\/\/192.168.1.104<br \/>\nOptions Follow<br \/>\nSymLinksOrder allow,denyAllow from all<br \/>\n&lt;\/Proxy&gt;<br \/>\nProxyPass \/myCluster balancer:\/\/mycluster<\/p>\n<p>root@www1 ~]#<br \/>\nvi \/etc\/httpd\/conf.d\/proxy.conf<br \/>\n# create new<\/p>\n<p>&lt;IfModule mod_proxy.c&gt;<br \/>\nProxyRequests Off<br \/>\n&lt;Proxy *&gt;<br \/>\nOrder deny,allow<br \/>\nAllow from all<br \/>\n&lt;\/Proxy&gt;<\/p>\n<p># specify the way of load balancing with &#8220;lbmethod&#8221;. it&#8217;s also possible to set &#8220;bytraffic&#8221;.<\/p>\n<p>ProxyPass \/proxy balancer:\/\/cluster lbmethod=byrequests<br \/>\n&lt;proxy balancer:\/\/cluster&gt;<br \/>\nBalancerMember http:\/\/www1.rmohan.com loadfactor=1<br \/>\nBalancerMember http:\/\/www2.rmohan.com loadfactor=1<br \/>\n&lt;\/proxy&gt;<br \/>\n&lt;\/IfModule&gt;<br \/>\n[root@www ~]#<br \/>\n\/etc\/rc.d\/init.d\/httpd restart<\/p>\n<p>Stopping httpd:<br \/>\n[\u00a0 OK\u00a0 ]<\/p>\n<p>Starting httpd:<br \/>\n[\u00a0 OK\u00a0 ]<\/p>\n<p style=\"text-align: left;\">\n","protected":false},"excerpt":{"rendered":"<p style=\"text-align: left;\">Apache mod_proxy as Load Balancer<\/p>\n<p style=\"text-align: left;\">This article presents an example of load balancing using Apache2.<\/p>\n<p>For example take the host 192.168.1.100 as a balancer, this host will install the apache front end acting for all requests and will balance the load on other hosts.<\/p>\n<p>The load is redirected to the host [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/428"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=428"}],"version-history":[{"count":3,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/428\/revisions"}],"predecessor-version":[{"id":431,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/428\/revisions\/431"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}