How to configure JBoss 7 to serve different default war for specific hostnames (with SSL)
aogier Dec 18, 2012 6:35 AM(Also asked on stackoverflow)
Here is my use case.
I want to use JBoss 7 to serve 2 different webapps (war) depending on the hostname which is used inside the HTTP request :
- When I access to https://app1.mydomain.com/, JBoss must serve
app1.war
with the SSL certificate "app1.mydomain.com" - When I access to https://app2.mydomain.com/, JBoss must serve
app2.war
with the SSL certificate "app2.mydomain.com"
I would prefer that the appX.war
were used as root context for each hostname (accessing tohttps://appX.mydomain.com/index.html would use the appX.war/index.html
file), but I could accept going to https://appX.mydomain.com/appX/ to access my appX
(X
is 1
or 2
).
Moreover I would want to use a single IP & port for that configuration, but this seems to be not possible (according to that SO answer & that one) without using Appache HTTPD as a proxy. It would be the alternative but I would prefer not using it.
I tried to configure that with the standalone
mode (and by using different IP). Here is an extract from my standalone.xml
:
{code:xml}
...
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="app1.mydomain.com" native="true">
<connector name="https-app1" protocol="HTTP/1.1" scheme="https" socket-binding="app1-https" secure="true">
<ssl password="pass1" certificate-key-file="${jboss.server.config.dir}/cert/app1.mydomain.com.key" protocol="TLSv1" verify-client="false" certificate-file="${jboss.server.config.dir}/cert/app1.mydomain.com.crt"/>
</connector>
<connector name="https-app2" protocol="HTTP/1.1" scheme="https" socket-binding="app2-https" secure="true">
<ssl password="pass2" certificate-key-file="${jboss.server.config.dir}/cert/app2.mydomain.com.key" protocol="TLSv1" verify-client="false" certificate-file="${jboss.server.config.dir}/cert/app2.mydomain.com.crt"/>
</connector>
<virtual-server name="app1.mydomain.com" enable-welcome-root="false" default-web-module="app1">
<alias name="app1.mydomain.com"/>
</virtual-server>
<virtual-server name="app2.mydomain.com" enable-welcome-root="false" default-web-module="app2">
<alias name="app2.mydomain.com"/>
</virtual-server>
...
<interfaces>
<interface name="app1.mydomain.com">
<inet-address value="10.0.0.1"/>
</interface>
<interface name="app2.mydomain.com">
<inet-address value="10.0.0.2"/>
</interface>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="app1-https" interface="app1.mydomain.com" port="443" fixed-port="true"/>
<socket-binding name="app2-https" interface="app2.mydomain.com" port="443" fixed-port="true"/>
...
{code}
But that not seems to work as expected...
- When I access to https://app1.mydomain.com/ I see my welcome file of my
app1.war
(I think this is due to thedefault-virtual-server
attribute) - When I access to https://app1.mydomain.com/app1/ I see a 404 report (with HTML body content)
- When I access to https://app1.mydomain.com/app2/ I see my welcome file of my
app2.war
- When I access to https://app2.mydomain.com/, https://app2.mydomain.com/app1/ orhttps://app2.mydomain.com/app2/, JBoss only answers an HTTP "404 Not Found" without any body HTML content, so my page is blank.
Is this a bug from JBoss 7.1.1.Final ?
Does anyone has an idea ?