Recently I’ve been changing a cluster configuration. Maybe it isn’t a real cluster, it looks more like a cloud or load balancer. The ingredients are as follow:berryjam.ruhttp://dekor-okno.ru

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:

The second thing was to enable use of aliases (and disabling advertising as it isn’t supported by Amazon EC2)

Also on JBoss AS I had to define the 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:

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: