Using the Portal Manager with Named Virtual Hosts

With CMS Fiona, several websites can be operated on name-based virtual hosts. The websites are maintained with the CMS as separate instances and are served dynamically by the Portal Manager. It is possible to use the same instance for several virtual hosts.

Prerequisites and Mode of Operation

For operating the virtual hosts, Apache webserver with mod_jk, Trifork Application Server, and our Portal Manager are required.

For Apache webserver to accept requests sent to the virtual hosts and redirect them to the Trifork server using mod_jk, the following directive in the Apache configuration is used:

  jkMount /* triforkWorker

The Trifork server in turn redirects the requests to the Portal Manager web application which, based on its configuration, determines the content assigned to the virtual host. For this, the VirtualHostConfig configuration element is used.

Since only one document root directory exists in the Portal Manager configuration (documentSource) for all virtual hosts, it is set to any directory in which then a symbolic link is created for each virtual host. The symbolic links point to the content associated with the corresponding virtual hosts.

Sample Configuration

Apache

  # /etc/httpd/httpd.conf
  ...
  NameVirtualHost 10.1.110.40:80
  NameVirtualHost 10.1.110.40:443
  <VirtualHost 10.1.110.40:80>
    ServerName www.example.org
    ServerAlias example.org
    ErrorLog  /var/log/httpd/error_log
    CustomLog /var/log/httpd/www.example.org-access_log combined    
    CustomLog /var/log/httpd/www.example.org-redir_log redirectlog
    JkMount /* triforkWorker
    ...
  </VirtualHost>
  <VirtualHost 10.1.110.40:80>
    ServerName www.example.com
    ErrorLog  /var/log/httpd/error_log
    CustomLog /var/log/httpd/www.example.com-access_log combined
    JkMount /* triforkWorker
  </VirtualHost>
   
  # /etc/httpd/workers.properties

  worker.list=triforkWorker
  # Set properties for triforkWorker (ajp13)
  worker.triforkWorker.type=ajp13
  worker.triforkWorker.host=localhost
  worker.triforkWorker.port=8009
  worker.triforkWorker.lbfactor=250
  worker.triforkWorker.cachesize=50
  worker.triforkWorker.cache_timeout=300
  worker.triforkWorker.socket_keepalive=1
  worker.triforkWorker.recycle_timeout=300

Portal Manager

Here, one Portal Manager is used for all the virtual hosts. However, you might also define several workers in the Apache configuration to assign the virtual hosts to any number of Portal Managers. This might be done to improve the performance with Portal Managers running on individual computers.

  # /opt/Infopark/CMS-Fiona/instance/internet/webapps/PM/WEB-INF/pm.xml
  ...
  <bean id="hostConfig" class="com.infopark.pm.VirtualHostConfig">
    <property name="properties">
      <props>
        <prop key="example_org.locales">de</prop>
        <prop key="example_org.http.enable">true</prop>
        <prop key="example_org.http.host">www.example.org</prop>
        <prop key="example_org.http.port">80</prop>
        <prop key="example_com.locales">en</prop>
        <prop key="example_com.http.enable">true</prop>
        <prop key="example_com.http.host">www.example.com</prop>
        <prop key="example_com.http.port">80</prop>
      </props>
    </property>
  </bean>
  ...
  <bean id="documentSource" class="com.infopark.pm.doc.WebappDocumentSource">
    <property name="documentSource">
      <bean class="com.infopark.pm.FileDocumentSource">
        <property name="documentRoot" value="/var/www/vhosts" />
        <property name="inputEncoding" value="UTF-8" />
      </bean>
    </property>
    <property name="inputEncoding" value="ISO-8859-1" />
  </bean>
  ...

Creating Symbolic Links

Afterwards, the symbolic links are created in the directory that has been specified as the documentSource.

  cd /var/www/vhosts
  ln -s /opt/Infopark/CMS-Fiona/instance/internet/export/online/docs example_org
  ln -s /opt/Infopark/CMS-Fiona/instance/internet/export/online/docs example_com

Deploying the Portal Manager

Finally, the Portal Manager needs to be deployed again for the configuration changes to come into effect. For this, run the following command from the instance directory concerned:

  ./instance/instancename/bin/rc.npsd deploy PM