Application Virtual Hosts

Application Virtual Host

Virtual Host

If you ever need to deploy multiple applications on the same Jboss AS instance under the same context root (see below example), this can only be achieved using virtual hosts.

/myapp

The idea is very similar to the Apache setup where a particular site listens on a particaly Domain Name. Under Jboss, a application is listening under a particular domain. This allows you to have the following:

www.mydomainONE.com/myapp
www.mydomainTWO.com/myapp

Even if "myapp" is the same application, it can run under different domains for different clients.

You can also run the application under the root "/" context of the domain.

To achieve this you need to edit two files (NOTE The following configuration was done Jboss AS 4.2.3)

jboss-web.xml (This would be inside your application WAR file under the WEB-INF directory).
{code}/opt/jboss/server/<instance>/deploy/jboss-web.deployer/server.xml (Note <instance> represents you instance)

Inside your "jboss-web.xml" you need to define your virtual host and context

<jboss-web>
    <context-root>/myapp</context-root>
    <virtual-host>www.mydomainTWO.com</virtual-host>
</jboss-web>

You now need to edit the server.xml file for you Jboss webcontainer (Tomcat). Inside the <Engine> Tags you need to define you virtual host.

<Host name="www.mydomainTWO.com" autoDeploy="false" deployOnStartup="false" deployXML="false">
     <Alias>www.mydomainTWO.com</Alias>
</Host>

Once you have done this, you can restart the Jboss server and deploy you applications.

Comments

Anonymous says:

Thanku so much for this post..

Its crisp,clear and ver helful!!! :)

Anonymous says:

Helpful* :)


Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

 

Other Features

Add Content

- Add Comment