geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Geronimo v3.0 > Configuring Virtual Host in Jetty
Date Thu, 27 Jan 2011 03:48:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2036/9/4/_/styles/combined.css?spaceKey=GMOxDOC30&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Configuring+Virtual+Host+in+Jetty">Configuring
Virtual Host in Jetty</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~maojia508">maojia</a>
    </h4>
        <br/>
                         <h4>Changes (3)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{scrollbar} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">In
the</span> <span class="diff-added-words"style="background-color: #dfd;">The</span>
[Configuring Virtual Host in Tomcat] <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">section
we describe</span> <span class="diff-added-words"style="background-color: #dfd;">topic
introduces</span> how to define a Virtual Host in the Geronimo&#39;s {{config.xml}}
<span class="diff-added-words"style="background-color: #dfd;">file</span> so <span
class="diff-added-words"style="background-color: #dfd;">that</span> applications
can be deployed to specific hosts ( _Virtual Hosts_) with a minimal configuration on the application
deployment plans side. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">The</span>
<span class="diff-added-words"style="background-color: #dfd;">However, the</span>
need to define Virtual Hosts at the server level ( {{config.xml}} ) only applies to Geronimo
with Tomcat distributions. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >{excerpt}For the Jetty distribution
of Apache <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Geronimo
this</span> <span class="diff-added-words"style="background-color: #dfd;">Geronimo,</span>
configuration <span class="diff-added-words"style="background-color: #dfd;">Virtual
Host</span> is dramatically simpler.{excerpt} You just need to define the *&lt;virtual-host&gt;*
tag in the application&#39;s deployment plan and make sure that <span class="diff-added-words"style="background-color:
#dfd;">the</span> host name ( virtual host ) can be resolved by the client. There
is virtually no additional configuration needed on the Geronimo server side. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >In this <span class="diff-changed-words">example<span
class="diff-added-chars"style="background-color: #dfd;">,</span></span> we
continue to use the HelloWorld Web sample application covered in the [Quick start - Apache
Geronimo for the impatient] section. Here is a summary of steps <br></td></tr>
            <tr><td class="diff-unchanged" > <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p><a name="ConfiguringVirtualHostinJetty-top"></a></p>
<style type='text/css'>/*<![CDATA[*/
table.ScrollbarTable  {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color:
#f0f0f0}
table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}
table.ScrollbarTable td.ScrollbarPrevName {text-align: left;border: none;}
table.ScrollbarTable td.ScrollbarParent {text-align: center;border: none;}
table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;}
table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;}

/*]]>*/</style><div class="Scrollbar"><table class='ScrollbarTable'><tr><td
width='33%' class='ScrollbarPrevName'>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/GMOxDOC30/Configuring+virtual+host"><img border='0' align='middle'
src='/confluence/images/icons/up_16.gif' width='8' height='8'></a></sup><a
href="/confluence/display/GMOxDOC30/Configuring+virtual+host">Configuring virtual host</a></td><td
width='33%' class='ScrollbarNextName'>&nbsp;<a href="/confluence/display/GMOxDOC30/Configuring+Virtual+Host+in+Tomcat">Configuring
Virtual Host in Tomcat</a></td><td class='ScrollbarNextIcon'><a href="/confluence/display/GMOxDOC30/Configuring+Virtual+Host+in+Tomcat"><img
border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></div>

<p>The <a href="/confluence/display/GMOxDOC30/Configuring+Virtual+Host+in+Tomcat"
title="Configuring Virtual Host in Tomcat">Configuring Virtual Host in Tomcat</a>
topic introduces how to define a Virtual Host in the Geronimo's <tt>config.xml</tt>
file so that applications can be deployed to specific hosts ( <em>Virtual Hosts</em>)
with a minimal configuration on the application deployment plans side. However, the need to
define Virtual Hosts at the server level ( <tt>config.xml</tt> ) only applies
to Geronimo with Tomcat distributions. </p>

<p>For the Jetty distribution of Apache Geronimo, configuration Virtual Host is dramatically
simpler. You just need to define the <b>&lt;virtual-host&gt;</b> tag in
the application's deployment plan and make sure that the host name ( virtual host ) can be
resolved by the client. There is virtually no additional configuration needed on the Geronimo
server side.</p>

<p>In this example, we continue to use the HelloWorld Web sample application covered
in the <a href="/confluence/display/GMOxDOC30/Quick+start+-+Apache+Geronimo+for+the+impatient"
title="Quick start - Apache Geronimo for the impatient">Quick start &#45; Apache Geronimo
for the impatient</a> section. Here is a summary of steps</p>


<ol>
	<li>Create a <tt>app_home</tt> directory somewhere in the file system,
from now on we will reference this location as <tt>&lt;app_home&gt;</tt>.</li>
	<li>Create a <tt>HelloWorld.jsp</tt> file in the <tt>&lt;app_home&gt;</tt>
directory and paste the following content.
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>HelloWorld.jsp</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;html&gt;</span>
    <span class="code-tag">&lt;head&gt;</span>
        <span class="code-tag">&lt;jsp:useBean id=<span class="code-quote">"datetime"</span>
class=<span class="code-quote">"java.util.Date"</span>/&gt;</span>
        <span class="code-tag">&lt;title&gt;</span>Basic HelloWorld JSP<span
class="code-tag">&lt;/title&gt;</span>
    <span class="code-tag">&lt;/head&gt;</span>
    <span class="code-tag">&lt;body bgcolor=<span class="code-quote">"#909DB8"</span>&gt;</span>
        <span class="code-tag">&lt;h1&gt;</span><span class="code-tag">&lt;font
face=<span class="code-quote">"tahoma"</span> color=<span class="code-quote">"white"</span>&gt;</span>Hello
world from GERONIMO!<span class="code-tag">&lt;/font&gt;</span><span
class="code-tag">&lt;/h1&gt;</span>
        <span class="code-tag">&lt;font face=<span class="code-quote">"tahoma"</span>
color=<span class="code-quote">"white"</span>&gt;</span>on ${datetime}<span
class="code-tag">&lt;/font&gt;</span>
    <span class="code-tag">&lt;/body&gt;</span>
<span class="code-tag">&lt;/html&gt;</span>
</pre>
</div></div></li>
	<li>Create a <tt>WEB-INF</tt> directory under <tt>&lt;app_home&gt;</tt>.</li>
	<li>Create a <tt>web.xml</tt> file in the <tt>&lt;app_home&gt;\WEB-INF</tt>
directory and paste the following content.
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;web-app version=<span class="code-quote">"2.4"</span>

   xmlns=<span class="code-quote">"http://java.sun.com/xml/ns/j2ee"</span>
   <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;

    <span class="code-tag">&lt;welcome-file-list&gt;</span>
         <span class="code-tag">&lt;welcome-file&gt;</span>HelloWorld.jsp<span
class="code-tag">&lt;/welcome-file&gt;</span>
    <span class="code-tag">&lt;/welcome-file-list&gt;</span>

<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div></li>
	<li>Create a <tt>geronimo-web.xml</tt> file in the <tt>&lt;app_home&gt;\WEB-INF</tt>
directory and paste the following content.
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>geronimo-web.xml</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
<span class="code-tag">&lt;web-app xmlns=<span class="code-quote">"http://geronimo.apache.org/xml/ns/j2ee/web-1.2"</span>&gt;</span>
        <span class="code-tag">&lt;environment&gt;</span>
                <span class="code-tag">&lt;moduleId&gt;</span>
                        <span class="code-tag">&lt;groupId&gt;</span>sample.applications<span
class="code-tag">&lt;/groupId&gt;</span>
                        <span class="code-tag">&lt;artifactId&gt;</span>HelloWorldApp<span
class="code-tag">&lt;/artifactId&gt;</span>
                        <span class="code-tag">&lt;version&gt;</span>2.1<span
class="code-tag">&lt;/version&gt;</span>
                        <span class="code-tag">&lt;type&gt;</span>war<span
class="code-tag">&lt;/type&gt;</span>
                <span class="code-tag">&lt;/moduleId&gt;</span>      
      
        <span class="code-tag">&lt;/environment&gt;</span>
        <span class="code-tag">&lt;context-root&gt;</span>/hello<span
class="code-tag">&lt;/context-root&gt;</span>
        
        <span class="code-tag"><span class="code-comment">&lt;!-- Add this
line to define a new Virtual Host in Geronimo - Jetty  --&gt;</span></span>
        <span class="code-tag">&lt;virtual-host&gt;</span>virtualhost1.com<span
class="code-tag">&lt;/virtual-host&gt;</span>
<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div></li>
</ol>


<p>If you compare this deployment plan with the one described in the <a href="/confluence/display/GMOxDOC30/Quick+start+-+Apache+Geronimo+for+the+impatient"
title="Quick start - Apache Geronimo for the impatient">Quick start &#45; Apache Geronimo
for the impatient</a> section you will note that only one line has been added, that
is <tt>&lt;virtual-host&gt;virtualhost1.com&lt;/virtual-host&gt;</tt>.
This is all you need to define a virtual host in Geronimo with Jetty.</p>

<p>To deploy this application you can use the <b>--inPlace</b> option from
the deployer tool so you wont need to package the application nor copy it anywhere else. Just
run the following command:</p>

<p><b><tt>&lt;geronimo_home&gt;\bin\deploy --user system --password
manager deploy --inPlace &lt;app_home&gt;</tt></b></p>

<p><font color="white">
<div class="preformatted panel" style="background-color: #000000;border-style: solid;border-width:
1px;"><div class="preformattedContent panelContent" style="background-color: #000000;">
<pre>D:\geronimo-jetty6-jee5-2.1\bin&gt;deploy --user system --password manager
deploy --inPlace \HelloWorld_2.1
Using GERONIMO_BASE:   D:\geronimo-jetty6-jee5-2.1
Using GERONIMO_HOME:   D:\geronimo-jetty6-jee5-2.1
Using GERONIMO_TMPDIR: D:\geronimo-jetty6-jee5-2.1\var\temp
Using JRE_HOME:        C:\Java\jdk1.5.0_06\\jre
    Deployed sample.applications/HelloWorldApp/2.1/war @
    http://hcunico:8080/hello
</pre>
</div></div></font></p>


<p>Note that even when the successful deployment message on screen shows that the application
has been deployed to the <a href="http://XYZ:8080/hello" class="external-link" rel="nofollow">http://XYZ:8080/hello</a>
host, the application will only be accessible via the virtual host previously defined in the
<b>&lt;virtual-host&gt;</b> tag on the <tt>geronimo-web.xml</tt>
deployment plan.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Configuring+Virtual+Host+in+Jetty">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=20645458&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Configuring+Virtual+Host+in+Jetty?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message