{"id":1158,"date":"2012-08-28T08:42:19","date_gmt":"2012-08-28T00:42:19","guid":{"rendered":"http:\/\/rmohan.com\/?p=1158"},"modified":"2012-08-28T08:42:54","modified_gmt":"2012-08-28T00:42:54","slug":"jboss-mod-cluster","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1158","title":{"rendered":"Jboss Mod cluster"},"content":{"rendered":"<ul>\n<li><a title=\"JBoss AS\" href=\"http:\/\/www.jboss.org\/jbossas\/downloads\/\" target=\"_blank\"> JBoss AS version 6<\/a><\/li>\n<li><a title=\"mod_cluster\" href=\"http:\/\/www.jboss.org\/mod_cluster\" target=\"_blank\">mod_cluster 1.1<\/a><\/li>\n<li><a title=\"Apache HTTPD\" href=\"http:\/\/httpd.apache.org\/\" target=\"_blank\">Apache HTTPD server<\/a><\/li>\n<\/ul>\n<p>The problem I had was that I just want to enable clustering for given VirtualHost section and not for the whole Web server. Current configuration was quite simple, as you can find out on mod_cluster\u2019s <a title=\"mod_cluster example configuration\" href=\"http:\/\/docs.jboss.org\/mod_cluster\/1.1.0\/html\/native.config.html#MinimalExample\" target=\"_blank\">web page<\/a>. On the JBoss AS side you must uncomment one line or so and provide list with mod_cluster enabled web servers.. But as I said, such configuration enable clustering for the entire web server. I didn\u2019t want that, as I want to create another Virtual Host to serve static content.<\/p>\n<p>So, the first step was to read the documentation, but it didn\u2019t answer my questions. I was trying many different configurations and what I\u00a0achieved\u00a0was a separation of Virtual Hosts \u2013 I could define the different clusters for different Virtual Hosts, but still wasn\u2019t able to serve static content <img decoding=\"async\" src=\"http:\/\/dailylog.lenart.org.pl\/wp-includes\/images\/smilies\/icon_razz.gif\" alt=\":P\" \/><\/p>\n<p>The answer was simple, just disable creation of balancer for all Virtual hosts with this directive:<\/p>\n<pre>CreateBalancers 1<\/pre>\n<p>The second thing was to enable use of aliases<\/p>\n<pre>UseAlias 1\r\nServerAdvertise Off<\/pre>\n<p>Also on JBoss AS I had to define the Alias:<\/p>\n<pre>&lt;Host name=\"localhost\"&gt;\r\n&lt;Alias&gt;my.domain.com&lt;\/Alias&gt;\r\n...<\/pre>\n<p>The rest was easy, just I have had to enable use of Virtual Hosts on given IP address, specify the web server name and define the Virtual Hosts. After restart everything seemed to work perfectly. I had static pages under one domain name and an application under second. The only problem was that I wasn\u2019t able to login to the application. Why? Simply, my session wasn\u2019t a Sticky Session. And not because JBoss server didn\u2019t support it. Much simpler. My session ID wasn\u2019t passed to the JBoss server and back to the Apache HTTPD <img decoding=\"async\" src=\"http:\/\/dailylog.lenart.org.pl\/wp-includes\/images\/smilies\/icon_biggrin.gif\" alt=\":D\" \/><\/p>\n<p>To solve that I just had to add ProxyPass and ProxyPassReverse directive:<\/p>\n<pre>ProxyPass \/ balancer:\/\/mycluster\/ stickysession=JSESSIONID|jsessionid nofailover=On\r\nProxyPassReverse \/ balancer:\/\/mycluster\/ stickysession=JSESSIONID|jsessionid<\/pre>\n<p>And that was the end, everything was working smoothly. But the customer decide not to use the same server for load balancing and serving static pages. So all my work was useless, except experience I\u2019ve got<\/p>\n<p>Anyway it\u2019s a very elastic configuration, as you can add another JBoss servers and attach them to the cloud in a minute.<\/p>\n<p>The whole configuration just for future reference:<\/p>\n<pre>LoadModule proxy_module \/usr\/lib\/apache2\/modules\/mod_proxy.so\r\nLoadModule proxy_module \/usr\/lib\/apache2\/modules\/mod_proxy.so\r\nLoadModule proxy_ajp_module \/usr\/lib\/apache2\/modules\/mod_proxy_ajp.so\r\nLoadModule slotmem_module \/usr\/lib\/apache2\/modules\/mod_slotmem.so\r\nLoadModule manager_module \/usr\/lib\/apache2\/modules\/mod_manager.so\r\nLoadModule proxy_cluster_module \/usr\/lib\/apache2\/modules\/mod_proxy_cluster.so\r\nLoadModule advertise_module \/usr\/lib\/apache2\/modules\/mod_advertise.so\r\nLoadModule rewrite_module \/usr\/lib\/apache2\/modules\/mod_rewrite.so\r\n\r\nServerName www.domain.com\r\nNameVirtualHost 10.10.10.10:80\r\nDocumentRoot \/var\/www\r\n\r\nCreateBalancers 1\r\nServerAdvertise Off\r\nUseAlias 1\r\n\r\n&lt;VirtualHost 10.10.10.10:80&gt;\r\n    DocumentRoot \/var\/www\r\n    ServerName www.domain.com\r\n    ServerAlias domain.com\r\n&lt;\/VirtualHost&gt;\r\n\r\n&lt;VirtualHost 10.10.10.10:80&gt;\r\n    ServerName my.domain.com\r\n    ProxyPass \/ balancer:\/\/mycluster\/ stickysession=JSESSIONID|jsessionid nofailover=On\r\n    ProxyPassReverse \/ balancer:\/\/mycluster\/ stickysession=JSESSIONID|jsessionid\r\n    &lt;Location \/status&gt;\r\n        SetHandler mod_cluster-manager\r\n        Order deny,allow\r\n        Deny from all\r\n        Allow from 127.0.0.1\r\n        #Allow from all\r\n    &lt;\/Location&gt;\r\n\r\n    KeepAliveTimeout 60\r\n    MaxKeepAliveRequests 0\r\n\r\n&lt;\/VirtualHost&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p> JBoss AS version 6 mod_cluster 1.1 Apache HTTPD server <\/p>\n<p>The problem I had was that I just want to enable clustering for given VirtualHost section and not for the whole Web server. Current configuration was quite simple, as you can find out on mod_cluster\u2019s web page. On the JBoss AS side you must uncomment [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1158"}],"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=1158"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1158\/revisions"}],"predecessor-version":[{"id":1160,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1158\/revisions\/1160"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}