Setting up httpd and opentaps with mod jk
opentaps has an embedded Apache Tomcat container, 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 (commonly known as "apache") web server to serve the static content or PHP and Perl scripts as well. This could be done by using the mod_jk module of Apache httpd server to serve up all your content and asking httpd to pull content from opentaps via the AJP13 protocol. Apache httpd could be instructed to forward requests that follow a certain pattern over to Tomcat and opentaps and serve up the results.
To configure mod_jk to point to opentaps, first configure the opentaps Tomcat container 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 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/ajp.html 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="0.0.0.0"/> <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"/> </property>
Next, configure the apache httpd server to forward requests over to opentaps via AJP13. The following example applies to Red Hat Enterprise Linux 5. You would need to create a file /etc/httpd/conf/workers.properties:
#list of workers worker.list=worker1, worker2 # main opentaps worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 # test opentaps worker.worker2.type=ajp13 worker.worker2.host=localhost worker.worker2.port=8010 # mappings /ecommerce/*=worker2 /ecommerce_testing/*=worker2
In this example, I have created two forwarding requests, so "/ecommerce/*" goes over port 8009 to my production instance of opentaps, and "/ecommerce_testing/*" goes over port 8010 to a testing instance of opentaps.
Finally, create a file /etc/httpd/conf.d/opentaps.conf and mount these workers for httpd:
LoadModule jk_module modules/mod_jk.so JkMount /ecommerce/* worker1 JkMount /ecommerce_testing/* worker2
You will also need to specify the forwarding for secured requests in the file /etc/httpd/conf.d/ssl.conf:
JkMount /ecommerce/* worker1 JkMount /ecommerce_testing/* worker2
Apache httpd should load these files automatically.