ParaViewWeb with Apache as front-end: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
 
(8 intermediate revisions by the same user not shown)
Line 3: Line 3:
== Introduction ==
== 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 an Apache server on the front of all your servers to dispatch all the client requests to the proper server.
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 be pretty close.
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.
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.


Line 11: Line 11:


=== Enable required modules ===
=== Enable required modules ===
Install packages for apache
  apt-get install apache2 libapache2-mod-jk libapache2-mod-proxy-html


Those command lines needs to be executed as root.
Those command lines needs to be executed as root.


   a2enmod proxy
   a2enmod proxy
   a2enmod proxy-ajp
   a2enmod proxy_ajp
   a2enmod proxy-http
  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 ===
=== Define a new Virtual host ===
Line 32: Line 60:


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


Line 41: Line 69:


   a2ensite paraviewweb
   a2ensite paraviewweb
=== Restart Apache ===
This command line needs to be executed as root.
  /etc/init.d/apache2 restart


== Tomcat ==
== Tomcat ==
Line 46: Line 81:
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 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:
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.
* 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 ===
=== Setup an HTTP/AJP connector ===
Line 59: Line 95:
         <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"  
         <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"  
               proxyPort="80"
               proxyPort="80"
               proxyName="YOUR_HOST_NAME" />   
               proxyName="YOUR_SERVER_HOSTNAME" />   
   
   
         <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"  
         <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"  
               proxyPort="80"
               proxyPort="80"
               proxyName="YOUR_HOST_NAME" />
               proxyName="YOUR_SERVER_HOSTNAME" />
       [...]
       [...]
       </Service>
       </Service>
  </Server>
  </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

Latest revision as of 13:42, 8 March 2012

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

Install packages for apache

 apt-get install apache2 libapache2-mod-jk libapache2-mod-proxy-html

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