Tuesday, July 11, 2006

Virtual Hosts On Orion

Setup up multiple domains using a single IP address.
That the client browser is HTTP 1.1 compliant.
The domain names point to the servers single IP address.
Example Domains: www.example1.com, www.example2.com
Example IP Address: 127.0.0.1

Objective

Setup up multiple domains using a single IP address.

Requirements

That the client browser is HTTP 1.1 compliant.
The domain names point to the servers single IP address.

Limitations

This is a very basic example, it does not take into account using shared applications or event the use of .war or .ear files. This is left as an exercise for the reader.
Example Domains: www.example1.com, www.example2.com
Example IP Address: 127.0.0.1

Steps

Create directories under $ORION_HOME\applications\ for each domain.
mkdir $ORION_HOME\applications\example1
mkdir $ORION_HOME\applications\example2

Each directory should contain a index.html file.
Contents of $ORION_HOME\applications\example1\index.html:

<html><head><title>www.example1.com</title></head>
<body bgcolor="#FFFFFF">
<h2>www.example1.com</h2>
</body>
</html>

Contents of $ORION_HOME\applications\example2\index.html:

<html><head><title>www.example2.com</title></head>
<body bgcolor="#FFFFFF">
<h2>www.example2.com</h2>
</body>
</html>

Create WEB-INF directories for the domains.

mkdir $ORION_HOME\applications\example1\WEB-INF
mkdir $ORION_HOME\applications\example2\WEB-INF

Each WEB-INF directory should contain a web.xml file.
Contents of $ORION_HOME\applications\example1\WEB-INF\web.xml

<web-app>
<display-name>Example 1</display-name>
<description>
example1
</description>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Contents of $ORION_HOME\applications\example2\WEB-INF\web.xml

<web-app>
<display-name>Example 2</display-name>
<description>
example2
</description>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

Create web-site XML file for each domain.
Contents of $ORION_HOME\config\example1-web-site.xml:

<web-site host="127.0.0.1" port="80" display-name="Example 1" virtual-hosts="www.example1.com">
<!-- The default web-app for this site, bound to the root -->
<default-web-app application="default" name="example1" />
<access-log path="../log/example1-web-access.log" />
</web-site>
Contents of $ORION_HOME\config\example2-web-site.xml:

<web-site host="127.0.0.1" port="80" display-name="Example 2" virtual-hosts="www.example2.com">
<!-- The default web-app for this site, bound to the root -->
<default-web-app application="default" name="example2" />
<access-log path="../log/example2-web-access.log" />
</web-site>
Edit $ORION_HOME\config\application.xml. Add the following lines:

<web-module id="example1" path="../applications/example1" />
<web-module id="example2" path="../applications/example2" />
Edit $ORION_HOME\config\server.xml. Add the following lines:

<web-site path="./example1-web-site.xml" />
<web-site path="./example2-web-site.xml" />


Restart Orion and test.

(OrionSupport Author's note: if you'd like the machine's IP to be usable for direct access, you'll want to add the IP as a virtual host on one of the web site configuration files, too.)

No comments: