Sooner or later it would have to come to this. We decided we wanted to setup our application server so that we would end up with two virtual hosts
- One providing a set of j2ee applications that will be accessible via port 80. This will be used by intra net users
- Another virtual host, providing an application named MyApp deployed into an OC4J Instance called OC4J_MYAPP that will be accessible via a different DNS name and used by internet users. The actual application will be accessed via SSL provided by a firewall / SSL Converter hosted on a different machine.
The first thing that needed to be done was to enable Apache to run as root and change the listening port to 80. See previous post Oracle IAS 10g 10.1.3.x Enable Apache to run as root and set the default HTTP port to 80 (non SSL)
The next thing was to set up the virtual host. environment. This includes creating a location for the static documents and he log files. In our case I created a websites directory and added a virtual-host-name directory with two subdirs named htdocs and logs.
You then have to go through the patching part and there is no way you can know this unless somebody from Oracle Support tells you. (Thanks Dan!) Out of the box 10.1.3.1 Oracle IAS needs two patches to be applied one 5555875 is the one that will allow your virtual host to be able to mount OC4J exported applications and the second one 5669155 will be the one that will patch the opatch utility so it will install the first one. Both patchsets are available from Oracle metalink.
After you have successfully applied patch numbers 5669155 and 5555875 in sequence, you will have to modify the the httpd.conf file located in
$ORACLE_HOME/Apache/Apache/conf/httpd.conf and add a VirtualHost entry to specify the details of your virtual host. My file looks more or less like this
# Defualt virtual host NameVirtualHost * # here is where you must enable acess to EM website and other applications # so they may be available from the default host <VirtualHost *> Oc4jMountCopy on Oc4jMount /em home Oc4jMount /em/* home </VirtualHost> # Virtual host for example.com Oc4jRoutingMode Static <VirtualHost *> # Unique location where a unique index.html file exists: DocumentRoot /home/oracle/websites/www.example.com/htdocs # Name used for this VirtualHost: ServerName www.example.com # For this purpose, we may need also access on port 80: Port 80 ServerAdmin email@example.com # Must appear in one line CustomLog "|/home/oracle/product/10.1.3.1/OracleAS_1/Apache/Apache /bin/rotatelogs /home/oracle/websites/www.example.com/logs/access_log 43200" common Oc4jMountCopy off Oc4jMount /MyApp OC4J_MYAPP Oc4jMount /MyApp/* OC4J_MYAPP </VirtualHost>
More or less that does it.
- The details can be found in the Apache documentation for virtual hosts, from where the basic idea is summarized as follows:
When a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then it will look at each
section with a matching IP address and try to find one where the ServerName or ServerAlias matches the requested hostname. If it finds one, then it uses the configuration for that server. If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used.
As a consequence, the first listed virtual host is the default virtual host. The DocumentRoot from the main server will never be used when an IP address matches the NameVirtualHost directive. If you would like to have a special configuration for requests that do not match any particular virtual host, simply put that configuration in a &th;VirtualHost> container and list it first in the configuration file.
opmnctl restartproc process-type=HTTP_Server
and it works.
Just one final touch. Since the virtual server will be the home for a single j2ee application, it might be convinient that the static index.html page of the new virtual host directly sends visitors to the j2ee application URL. This is as easy as adding
<meta http-equiv="refresh" content="0; url=/MyApp">
And think that now we are ready.