What are Virtual Hosts? What are they used for?
It allows multiple hosts to get associated with only one IP Address. The advantage of having multiple hosts associated with one IP Address is that the server will now be able to redirect requests coming for different hostnames either to different root directories to access the resources from OR to different web applications. The server will obviously maintain a mapping between the hostnames and root directories (or web applications) to decide the target of any incoming request.
Tomcat facilitates many-to-many bindings of host names and web applications. Tomcat's aliases feature is used to have multiple host names bound to the same web application deployed on it.
Example: a typical host entry for Tomcat
<Host name="www.domainName.com" appBase="Application Base Directory" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Alias>alternateDomainName1.com</Alias> <Alias>alternateDomainName2.org</Alias>
......
<Context path="/webApp" docBase="Context Root for this web app" debug="0" reloadable="false"/>
</Host>
Once this entry is added to the Tomcat then all the alternateDomainName(s) will also start pointing to the same web application referred to by the Context element. The Context element will have the path attribute as "" in case the directory name of the deployed web application is ROOT otherwise path will have the name of the directory (preceded by "/") under which the particular web application has been deployed on the Tomcat server.
Wednesday, June 11, 2008
What are Virtual Hosts? What are they used for?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment