Setting Up Virtual Hosts


Virtual hosts allow you to group web applications according to the various DNS names by which the machine running JBoss is known. For example, consider the server.xml configuration file given in Listing 9.1. This configuration defines a default host named vhost1.mydot.com and a second host named vhost2.mydot.com, which also has the alias www.mydot.com associated with it.

Listing 9.1. An Example of a Virtual Host Configuration
 <Server>    <Service name="jboss.web"       className="org.jboss.web.tomcat.tc5.StandardService">       <!-- A HTTP/1.1 Connector on port 8080 -->       <Connector port="8080" address="${jboss.bind.address}"                  maxThreads="150" minSpareThreads="25" maxSpareThreads="75"                  enableLookups="false" redirectPort="8443" acceptCount="100"                  connectionTimeout="20000" disableUploadTimeout="true"/>       <Engine name="jboss.web" defaultHost="vhost1">          <Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"                 certificatePrincipal= "org.jboss.security.auth.certs.SubjectDNMapping"             />          <Logger className="org.jboss.web.tomcat.Log4jLogger"                  verbosityLevel="WARNING"                  category="org.jboss.web.localhost.Engine"/>             <Host name="vhost1" autoDeploy="false"                   deployOnStartup="false" deployXML="false">                 <Alias>vhost1.mydot.com</Alias>                 <Valve className="org.apache.catalina.valves.AccessLogValve"                        prefix="vhost1" suffix=".log" pattern="common"                        directory="${jboss.server.home.dir}/log"/>                 <DefaultContext cookies="true" crossContext="true" override= "true"/>             </Host>             <Host name="vhost2" autoDeploy="false"                   deployOnStartup="false" deployXML="false">                 <Alias>vhost2.mydot.com</Alias>                 <Alias>www.mydot.com</Alias>                 <Valve className="org.apache.catalina.valves.AccessLogValve"                        prefix="vhost2" suffix=".log" pattern="common"                        directory="${jboss.server.home.dir}/log"/>                 <DefaultContext cookies="true" crossContext="true" override= "true"/>             </Host>       </Engine>    </Service> </Server> 

When a WAR file is deployed, it is by default associated with the virtual host whose name matches the defaultHost attribute of the containing Engine. To deploy a WAR to a specific virtual host, you need to specify an appropriate virtual-host definition in your jboss-web.xml descriptor. The following jboss-web.xml descriptor demonstrates how to deploy a WAR to the virtual host www.mydot.com. Note that you can use either the virtual hostname in the config file or the actual hostname:

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



JBoss 4. 0(c) The Official Guide
JBoss 4.0 - The Official Guide
ISBN: B003D7JU58
EAN: N/A
Year: 2006
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net