My JBoss 7.1 (standalone.xml) is configured like this:
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
<virtual-server name="default-host" enable-welcome-root="false" default-web-module="mydefaultapp">
<alias name="localhost"/>
<alias name="www.mydefaultapp.it"/>
</virtual-server>
<virtual-server name="secondApp" enable-welcome-root="false" default-web-module="secondApp">
<alias name="www.secondapp.com"/>
</virtual-server>
</subsystem>
'mydefaultapp' defines "/" as context-root in jboss-web.xml file and is running perfectly with mod_jk:
<VirtualHost *:80>
ServerName www.mydefaultapp.it
DocumentRoot /var/www/mydefaultapp
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mydefaultapp>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnvIf Request_URI "/foto/*" no-jk
JkMount / ajp13
JkMount /* ajp13
</VirtualHost>
Now I have that 'secondapp' war which doesn't define a context-root so it assumes '/secondapp'. If I try to deploy it with '/' context-root I get this error:
INSTALL: Failed to process phase INSTALL of deployment "foo.war" Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.web.deployment.default-host./.realm is already registered
If I deploy it with '/secondapp' context-root nothing works. Simply www.secondapp.com ends in 404 not found error.
A possible solution would be using http proxy with this configuration:
<VirtualHost *:80>
ServerName www.secondapp.com
ProxyPass / http://localhost:8080/secondapp/
ProxyPassReverse / http://localhost:8080/secondapp/
</VirtualHost>
which seems working but... I can't access jsf resources (I keep getting login form, there's some problem with my security)
Can you please suggest me the right configuration for having two domains, two wars with JBoss 7.1 + Apache2 + mod_jk. Remember the first one has "/" context-root while the second one has "/secondapp"
Finally I made it with mod_jk! It's about tag, it's confusing. I blogged about that: http://fabiobozzo.wordpress.com/2013/02/25/multiple-web-applications-with-jboss-and-apache/