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’s web page. 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’t want that, as I want to create another Virtual Host to serve static content.
So, the first step was to read the documentation, but it didn’t answer my questions. I was trying many different configurations and what I achieved was a separation of Virtual Hosts – I could define the different clusters for different Virtual Hosts, but still wasn’t able to serve static content
The answer was simple, just disable creation of balancer for all Virtual hosts with this directive:
CreateBalancers 1
The second thing was to enable use of aliases
UseAlias 1 ServerAdvertise Off
Also on JBoss AS I had to define the Alias:
<Host name="localhost"> <Alias>my.domain.com</Alias> ...
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’t able to login to the application. Why? Simply, my session wasn’t a Sticky Session. And not because JBoss server didn’t support it. Much simpler. My session ID wasn’t passed to the JBoss server and back to the Apache HTTPD
To solve that I just had to add ProxyPass and ProxyPassReverse directive:
ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On ProxyPassReverse / balancer://mycluster/ stickysession=JSESSIONID|jsessionid
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’ve got
Anyway it’s a very elastic configuration, as you can add another JBoss servers and attach them to the cloud in a minute.
The whole configuration just for future reference:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so LoadModule slotmem_module /usr/lib/apache2/modules/mod_slotmem.so LoadModule manager_module /usr/lib/apache2/modules/mod_manager.so LoadModule proxy_cluster_module /usr/lib/apache2/modules/mod_proxy_cluster.so LoadModule advertise_module /usr/lib/apache2/modules/mod_advertise.so LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so ServerName www.domain.com NameVirtualHost 10.10.10.10:80 DocumentRoot /var/www CreateBalancers 1 ServerAdvertise Off UseAlias 1 <VirtualHost 10.10.10.10:80> DocumentRoot /var/www ServerName www.domain.com ServerAlias domain.com </VirtualHost> <VirtualHost 10.10.10.10:80> ServerName my.domain.com ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On ProxyPassReverse / balancer://mycluster/ stickysession=JSESSIONID|jsessionid <Location /status> SetHandler mod_cluster-manager Order deny,allow Deny from all Allow from 127.0.0.1 #Allow from all </Location> KeepAliveTimeout 60 MaxKeepAliveRequests 0 </VirtualHost>
Recent Comments