Hyrax - Apache Integration

From OPeNDAP Documentation
Revision as of 00:22, 22 March 2007 by Ndp (talk | contribs) (New page: '''Request for Alternate Solutions:''' ''If these suggestions work for you then we are all happy. If you have a better method for achieving the same or similar goals then we would love to ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
⧼opendap2-jumptonavigation⧽

Request for Alternate Solutions: If these suggestions work for you then we are all happy. If you have a better method for achieving the same or similar goals then we would love to hear about it. If you're stuck and can't figure out how to achieve your goals, get in touch and I will try to help. - ndp (ndp at opendap dot org) Or email the OPeNDAP tech support list (opendap-tech at unidata dot ucar dot edu); see mail lists for information about the list.


Overview

If you are not concerned about the URL's for your data changing when you install tHyrax, then just run Tomcat as a standalone server. It can even be configured to operate on port 80, just like Apache. If however you want to keep your existing data access URL's intact, read on.

Many people deploying Hyrax have been using previous versions of the OPeNDAP servers with their data. These OPeNDAP servers required the Apache web server and utilized CGI to deliver their functionality. This is no longer the case, as Hyrax is a Java servlet designed to run in conjunction with Tomcat. However many OPeNDAP administrators may wish to keep the URL hierarchies of their existing systems unchanged and simply replace their existing implementation of the OPeNDAP server with the new server. To this end Tomcat needs to be integrated with the Apache installation. The directions here offer methods for integrating Hyrax with Apache version 2.x. If you are using earlier versions of Apache (1.x or older) you might wish to consider upgrading Apache to a more current version (version 2.x really is better...), otherwise these instructions may or may not be helpful.

There are 2 basic methods for integrating Apache and Tomcat. Both methods use the Apache mod_rewrite module. One of the methods requires the mod_jk module. In either case Tomcat must be running and listening on a port (which one depends on how you set things up) for it to interact with Apache.

mod_rewrite + mod_proxy

The simplest method for integrating Tomcat with Apache while preserving preexisting URL hierarchies is to use a mod_rewrite to implement a "reverse proxy". According to the Apache documentation this should be a secure arrangement.

mod_jk

Most discussions of integrating Tomcat and Apache start (and often end with) an Apache module called mod_jk, which allows Tomcat to work as part of Apache. However, mod_jk is generally not installed by default with Apache (while the rewrite and proxy modules are) so you will need to build Apache from source, using mod_jk seems both more complex and doesn't appear to offer any substantial performance improvements over the "reverse proxy" solution. That said, if you want to read about how to hook this all up using mod_jk then go here.



Install Hyrax

Install Hyrax as described in the installation instructions. No matter how you want things to end up you have to do this first.



Make sure your Apache has both mod_rewrite and mod_proxy modules

Depending on your Apache installation you may need to rebuild/compile Apache to enable rewrite and proxy. You should first look at the http.conf configuration file. Find the LoadModule directives and look for the lines that load the proxy and rewrite modules. They should look something like this:

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so

If you see the modules loaded then your set to go, skip to the next section.

If not then you will probably need to compile Apache from source and enable the rewrite and proxy modules.

  1. Make sure you have the Apache source.
  2. Run the Apache configure script with the --enable-rewrite and --enable-proxy switches. Minimally your configure command should look like this:

    ./configure --enable-rerwrite --enable-proxy

  3. (Re)compile.
  4. (Re)install.



Integrate Tomcat with Apache 2.x using mod_rewrite + mod_proxy

Advice: If you are not familiar with Apache mod_rewrite and mod_proxy go read about them now, before you do anything else.

Once you have Apache with these modules enabled you will need to edit Apache's httpd.conf file. Add the following lines:

    # Enable the rewrite module 
    RewriteEngine on
    # Target it's logging somewhere useful 
    RewriteLog /usr/local/apache2/logs/rewrite.log
    # Turn on logging (Set to 0 to disable) 
    RewriteLogLevel 2

    #Configure mod_proxy to disable everything except reverse proxies.
    ProxyRequests Off
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>

    # Uses a reverse proxy to enable mapping old OPeNDAP URL's to Tomcat.
    RewriteRule ^/cgi-bin/nph-dods(.*) http://<<your.server>>:8080/opendap/hyrax/$1 [P]
    RewriteRule ^/opendap/(.*) http://<<your.server>>:8080/opendap/$1 [P]

Assuming that your old OPeNDAP server was accessed via http://your.server/cgi-bin/nph-dods/ this will map it to the Hyrax servlet running in the Tomcat engine on the same system as your Apache server and listening on port 8080. You will need both of the RewriteRule directives, although you will probably tailor the first one to suit you previous server configuration, the second one should be as shown here. If you used Alias or AliasMatch with your old server, add more RewriteRule directives to get that same behavior.

Note: If you have AddEncoding directives in your Apache configuration, those will likely need to be replaced with AddType. If present, the AddEncoding directives will cause Apache 2.x to report that any page, such as the HTML form interface, is compressed, even though it is not. This problem can be very hard to track down.

    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    # Despite the name similarity, the following Add* directives have nothing
    # to do with the FancyIndexing customization directives above
    #
    # AddEncoding x-compress .Z
    # AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

Restart Apache (assuming Tomcat is already running) and you should be on your way.