Setting up httpd and opentaps with mod jk

From Opentaps Wiki
Jump to navigationJump to search

opentaps has an embedded Apache Tomcat server, which could be used to serve both dynamic content from opentaps and static content such as images and HTML files. You may, however, want to run the Apache httpd web server (commonly known as the "apache server") to serve your static HTML pages or images or PHP and Perl scripts for your site as well. This could be done by using Apache httpd as your main web server and using the mod_jk module to serve up content from opentaps via the AJP13 protocol. When properly configured, Apache httpd will forward all requests that follow a certain pattern over to the opentaps Tomcat serve and serve up the results, and the rest of the content would be served as usual with Apache httpd.

In this example, we will configure Apache httpd to serve up the ecommerce webstore requests to opentaps via mod_jk. First, configure the opentaps Tomcat server to listen to AJP13 requests. This is set in the ajp-container section of framework/base/config/ofbiz-containers.xml (or base/config/ofbiz-containers.xml), and the "port" property controls which port the ajp container listens on. Here is an example for configuring Tomcat to listen on port 8009:

        <property name="ajp-connector" value="connector">
            <!-- see for reference -->
            <property name="allowTrace" value="false"/>
            <property name="emptySessionPath" value="false"/>
            <property name="enableLookups" value="false"/>
            <property name="maxPostSize" value="2097152"/>
            <property name="protocol" value="AJP/1.3"/>
            <property name="proxyName" value=""/>
            <property name="proxyPort" value=""/>
            <property name="redirectPort" value=""/>
            <property name="scheme" value="http"/>
            <property name="secure" value="false"/>
            <property name="URIEncoding" value="UTF-8"/>
            <property name="useBodyEncodingForURI" value="false"/>
            <property name="xpoweredBy" value="true"/>
            <!-- AJP/13 connector attributes -->
            <property name="address" value=""/>
            <property name="backlog" value="10"/>
            <property name="maxSpareThreads" value="50"/>
            <property name="maxThreads" value="200"/>
            <property name="minSpareThreads" value="4"/>
            <property name="port" value="8009"/>
            <property name="tcpNoDelay" value="true"/>
            <property name="soTimeout" value="60000"/>
            <property name="tomcatAuthentication" value="true"/>

Next, configure the Apache httpd server to forward requests over to opentaps via AJP13. You will first need to install mod_jk for Apache httpd. In the case of Red Hat Red Hat Enterprise Linux 5, this can be done by installing the httpd-devel package. Next, you would need to create a file /etc/httpd/conf/ to define the forwarding routines:

#list of workers

# main opentaps

In this example, I have configured port 8009 to worker1. Finally, create a file /etc/httpd/conf.d/opentaps.conf and mount this worker for Apache httpd:

LoadModule    jk_module  modules/

JkMount  /ecommerce/* worker1

You will also need to specify the forwarding for secured requests in the file /etc/httpd/conf.d/ssl.conf:

JkMount  /ecommerce/* worker1

Restart your Apache httpd server, and it should load the opentaps.conf and the files automatically and forward all "ecommerce/" requests to the opentaps Tomcat server for processing.

Note In general we do not recommend forwarding /images/ over to Tomcat, as the Apache httpd is more efficient at serving static content. Therefore, we would recommend that you set up an /images/ directory in Apache httpd path or symlink it over to the /images/ and /opentaps_images/ directories in opentaps.