ParaViewWeb with Apache as front-end

From KitwarePublic
Jump to navigationJump to search

ParaViewWeb


Introduction

ParaViewWeb is a Web application written in Java that requires a Java based web server such as Tomcat or Jetty. Those servers tends to run on high port number such as 8080 or 9000 and if they are started from a regular user, they have not the right to listen on port 80 like the default HTTP usage expect. Moreover, if you want to integrate ParaViewWeb inside another web content that is served by another server technology such as Ruby, Python or PHP, you will need one Apache server on the front of all your servers to dispatch all the client requests to the proper server.

This wiki page explain how to setup a virtual host in between Tomcat and Apache2 inside an Ubuntu. For other systems, the paths may slightly vary, but the logic should remain the same. In order to allow better performance and streaming in image delivery, we use the ajp protocol, otherwise the default http protocol can work but will prevent the Java renderer from working due to data streaming issue.

Apache

Enable required modules

Those command lines needs to be executed as root.

 a2enmod proxy
 a2enmod proxy_ajp
 a2enmod proxy_http

Configure module proxy

Edit file /etc/apache2/mods-available/proxy.conf

 <IfModule mod_proxy.c>
       #turning ProxyRequests on and allowing proxying from all may allow
       #spammers to use your proxy to send email.

       ProxyRequests Off

       <Proxy *>
               AddDefaultCharset off
               Order deny,allow
               Deny from all
               Allow from all
       </Proxy>

       # Enable/disable the handling of HTTP/1.1 "Via:" headers.
       # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
       # Set to one of: Off | On | Full | Block

       ProxyVia On
 </IfModule>

Define a new Virtual host

Create a new file /etc/apache2/sites-available/paraviewweb

Using AJP protocol to allow streaming to work properly

<VirtualHost *:80>
  ProxyPass        /   ajp://localhost:8009/
  ProxyPassReverse /   ajp://localhost:8009/
</VirtualHost>

Using HTTP protocol will prevent Java renderer from working

<VirtualHost *:80>
  ProxyPass        /   http://localhost:8081/
  ProxyPassReverse /   http://localhost:8081/
</VirtualHost>

Enable Virtual host

This command line needs to be executed as root.

 a2ensite paraviewweb


Restart Apache

This command line needs to be executed as root.

 /etc/init.d/apache2 restart

Tomcat

In that case we supposed that tomcat has been download and installed in a user home directory and the tomcat used is not from the system package as that one already listen on port 80. In the following explanation, we will use file path that you will need to adjust based on your local setting. Here is the list of the variable name with their meaning that will need some adjustments:

  • TOMCAT_HOME: Directory that contains tomcat when you uncompressed it.
  • YOUR_SERVER_HOSTNAME: name used for your server when accessed by the web clients.

Setup an HTTP/AJP connector

Edit the file TOMCAT_HOME/conf/server.xml

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
    [...]
    <Service name="Catalina">
        <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" 
              proxyPort="80"
              proxyName="YOUR_SERVER_HOSTNAME" />  

        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" 
              proxyPort="80"
              proxyName="YOUR_SERVER_HOSTNAME" />
     [...]
     </Service>
</Server>

WebGL optimization

Apache can compress on the fly the HTTP content that come from the tomcat. In order to do so for the WebGL binary array, you'll need to enable the deflate module and configuring it for that specific content.

edit /etc/apache2/mods-available/deflate.conf

<IfModule mod_deflate.c>
         # these are known to be safe with MSIE 6
         AddOutputFilterByType DEFLATE text/html text/plain text/xml

         # everything else may cause problems with MSIE 6
         AddOutputFilterByType DEFLATE text/css
         AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
         AddOutputFilterByType DEFLATE application/rss+xml

         # Compress the ParaViewWeb WebGL binary content
         AddOutputFilterByType DEFLATE application/octetstream+webgl
</IfModule>

enable the module

a2enmod deflate