Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is how I did it, and I was also set up different SSL certs for each site (not shown). I don't claim to understand all I know but this is working for me in several installations. You need a "jetty.xml" and a "contexts.xml" file for each instance.</p> <p>Assume jetty is installed in /opt/Jetty...</p> <p>Launch two instances of the server referencing two versions of jetty.xml (this can be done in a single script, as shown, or in two separate launch scripts)</p> <p>start.sh...</p> <pre><code>cd /opt/Jetty java -jar start.jar etc/jetty.xml etc/jetty2.xml </code></pre> <p>If you have a server with multiple ip's you can use the context.xml files to specify different ip's or hostnames in the connector section of each jetty.xml file. If you only have one ip, then you will use the context path setting in context xml to differentiate between the two instances.</p> <p>in jetty.xml, refer to the <strong>ip or host</strong>, and the <strong>directory to contain the context.xml</strong> for the 1st instance:</p> <pre><code>&lt;Call name="addConnector"&gt; &lt;Arg&gt; &lt;New class="org.mortbay.jetty.nio.SelectChannelConnector"&gt; &lt;Set name="host"&gt;HOST OR IP FOR FIRST INSTANCE&lt;/Set&gt; &lt;Set name="port"&gt;&lt;SystemProperty name="jetty.port" default="80"/&gt;&lt;/Set&gt; &lt;Set name="maxIdleTime"&gt;30000&lt;/Set&gt; &lt;Set name="Acceptors"&gt;2&lt;/Set&gt; &lt;Set name="statsOn"&gt;false&lt;/Set&gt; &lt;Set name="confidentialPort"&gt;443&lt;/Set&gt; &lt;Set name="lowResourcesConnections"&gt;5000&lt;/Set&gt; &lt;Set name="lowResourcesMaxIdleTime"&gt;5000&lt;/Set&gt; &lt;/New&gt; &lt;/Arg&gt; &lt;/Call&gt; &lt;Call name="addLifeCycle"&gt; &lt;Arg&gt; &lt;New class="org.mortbay.jetty.deployer.ContextDeployer"&gt; &lt;Set name="contexts"&gt;&lt;Ref id="Contexts"/&gt;&lt;/Set&gt; &lt;Set name="configurationDir"&gt;&lt;SystemProperty name="jetty.home" default="."/&gt;/contexts/directory_for_FIRST_instance&lt;/Set&gt; &lt;Set name="scanInterval"&gt;5&lt;/Set&gt; &lt;/New&gt; &lt;/Arg&gt; &lt;/Call&gt; </code></pre> <p>in jetty.xml, refer to the <strong>ip or host</strong>, and the <strong>directory to contain the context.xml</strong> for the 2nd instance:</p> <pre><code>&lt;Call name="addConnector"&gt; &lt;Arg&gt; &lt;New class="org.mortbay.jetty.nio.SelectChannelConnector"&gt; &lt;Set name="host"&gt;HOST OR IP FOR SECOND INSTANCE&lt;/Set&gt; &lt;Set name="port"&gt;&lt;SystemProperty name="jetty.port" default="80"/&gt;&lt;/Set&gt; &lt;Set name="maxIdleTime"&gt;30000&lt;/Set&gt; &lt;Set name="Acceptors"&gt;2&lt;/Set&gt; &lt;Set name="statsOn"&gt;false&lt;/Set&gt; &lt;Set name="confidentialPort"&gt;443&lt;/Set&gt; &lt;Set name="lowResourcesConnections"&gt;5000&lt;/Set&gt; &lt;Set name="lowResourcesMaxIdleTime"&gt;5000&lt;/Set&gt; &lt;/New&gt; &lt;/Arg&gt; &lt;/Call&gt; &lt;Call name="addLifeCycle"&gt; &lt;Arg&gt; &lt;New class="org.mortbay.jetty.deployer.ContextDeployer"&gt; &lt;Set name="contexts"&gt;&lt;Ref id="Contexts"/&gt;&lt;/Set&gt; &lt;Set name="configurationDir"&gt;&lt;SystemProperty name="jetty.home" default="."/&gt;/contexts/directory_for_SECOND_instance&lt;/Set&gt; &lt;Set name="scanInterval"&gt;5&lt;/Set&gt; &lt;/New&gt; &lt;/Arg&gt; &lt;/Call&gt; </code></pre> <p><em>If defined as shown above, you can reload the war file and restart the application by touching the context xml file.</em></p> <p>Put separate context files in separate subdirectories of the context directory, each pointing to the same war file, but with different context paths and different virtual hosts.</p> <p>/opt/Jetty/contexts/subdirectory_for_first_instance/context_first.xml<br> /opt/Jetty/contexts/subdirectory_for_second_instance/context_second.xml</p> <p>in context_first.xml - you can specify a node (firstapp) that will always link to your first app</p> <pre><code>&lt;Set name="contextPath"&gt;/firstapp&lt;/Set&gt; </code></pre> <p>in context_second.xml - you can specify a node (firstapp) that will always link to your second app</p> <pre><code>&lt;Set name="contextPath"&gt;/secondapp&lt;/Set&gt; </code></pre> <p>(The above is necessary (two different context paths) if you want to run them from the same ip, i believe)</p> <p>Then define the two virtual hosts (must map the url which is being used by the browser) in the separate context files:<br> In context_first.xml:</p> <pre><code>&lt;Set name="virtualHosts"&gt; &lt;Array type="String"&gt; &lt;Item&gt;www.my_first_app.com&lt;/Item&gt; &lt;/Array&gt; &lt;/Set&gt; </code></pre> <p>And in context_second.xml</p> <pre><code>&lt;Set name="virtualHosts"&gt; &lt;Array type="String"&gt; &lt;Item&gt;www.my_second_app.com&lt;/Item&gt; &lt;/Array&gt; &lt;/Set&gt; </code></pre> <p>Note: if you have two ip's or host names, you can set the context path of both apps to "/"<br> if you have only one ip, the context path will determine which application is accessed</p> <p>Also, and importantly, you can send context parameters to your application so that it can determine which instance it is, if necessary.</p> <p>Example of context parameters to send unique values to each instance:</p> <pre><code> &lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt; &lt;!-- Custom context configuration --&gt; &lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt; &lt;Set name="initParams"&gt; &lt;New class="java.util.HashMap"&gt; &lt;Put name="customer"&gt;Joes Fish Store&lt;/Put&gt; &lt;Put name="ShowPanelNames"&gt;N&lt;/Put&gt; &lt;Put name="FiscalYearStartMonth"&gt;10&lt;/Put&gt; &lt;Put name="LiveEmail"&gt;Y&lt;/Put&gt; &lt;/New&gt; &lt;/Set&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload