[opencms-dev] Proxy Problems

??? shiys at langhua.cn
Sun Nov 21 17:59:49 CET 2004


Hi Oliver, hi list,

I'd like to share my experience on Apache-Tomcat integration with another way - mod_jk2. I write it down in the following, hope it's helpful to you.

Step 1. Install Apache 2.0.x in /apache2-path/ and Tomcat 4.1.x in /tomcat-path/.

Step 2. Install OpenCMS in /tomcat-path/webapps/cms/.

Step 3. Download mod_jk2 from http://jakarta.apache.org/tomcat/connectors-doc/jk2/ and install the mod_jk2.so in /apache2-path/modules/.

Step 4. Change the Tomcat's server.xml to:
<Server port="8005" shutdown="SHUTDOWN" debug="0">

  <Service name="Tomcat-Apache">

    <!-- Define an SSL HTTP/1.1 Connector on port 8443 -->
    <!--
    <Connector className="org.apache.catalina.connector.http.HttpConnector"
               port="8443" minProcessors="5" maxProcessors="75"
               enableLookups="true"
	       acceptCount="10" debug="0" scheme="https" secure="true">
      <Factory className="org.apache.catalina.net.SSLServerSocketFactory"
               clientAuth="false" protocol="TLS"/>
    </Connector>
    -->

    <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
               port="8009" minProcessors="5" maxProcessors="75"
               enableLookups="false" redirectPort="8443"
               acceptCount="10" debug="0" connectionTimeout="20000"
               URIEncoding="utf-8" useBodyEncodingForURI="true"
               useURIValidationHack="false"
               protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" />

    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host). -->

    <!-- Define the top level container in our container hierarchy -->
    <Engine name="Tomcat-Apache" defaultHost="localhost" debug="0">

      <!-- The request dumper valve dumps useful debugging information about
           the request headers and cookies that were received, and the response
           headers and cookies that were sent, for all requests received by
           this instance of Tomcat.  If you care only about requests to a
           particular virtual host, or a particular application, nest this
           element inside the corresponding <Host> or <Context> entry instead.

           For a similar mechanism that is portable to all Servlet 2.3
           containers, check out the "RequestDumperFilter" Filter in the
           example application (the source for this filter may be found in
           "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").

           Request dumping is disabled by default.  Uncomment the following
           element to enable it. -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- Global logger unless overridden at lower levels -->
      <Logger className="org.apache.catalina.logger.FileLogger"
              prefix="catalina_log." suffix=".txt"
              timestamp="true"/>

      <!-- Because this Realm is here, an instance will be shared globally -->

      <Realm className="org.apache.catalina.realm.MemoryRealm" />

      <!-- Replace the above Realm with one of the following to get a Realm
           stored in a database and accessed via JDBC -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
             driverName="org.gjt.mm.mysql.Driver"
          connectionURL="jdbc:mysql://localhost/authority"
         connectionName="test" connectionPassword="test"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
             driverName="oracle.jdbc.driver.OracleDriver"
          connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
         connectionName="scott" connectionPassword="tiger"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
             driverName="sun.jdbc.odbc.JdbcOdbcDriver"
          connectionURL="jdbc:odbc:CATALINA"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!-- Define the default virtual host -->
      <Host name="localhost" debug="0" appBase="webapps" 
       unpackWARs="true" autoDeploy="true">

        <!-- Normally, users must authenticate themselves to each web app
             individually.  Uncomment the following entry if you would like
             a user to be authenticated the first time they encounter a
             resource protected by a security constraint, and then have that
             user identity maintained across *all* web applications contained
             in this virtual host. -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn"
                   debug="0"/>
        -->

        <!-- Access log processes all requests for this virtual host.  By
             default, log files are created in the "logs" directory relative to
             $CATALINA_HOME.  If you wish, you can specify a different
             directory with the "directory" attribute.  Specify either a relative
             (to $CATALINA_HOME) or absolute path to the desired directory.
        -->
        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
                 pattern="common"/>

        <!-- Logger shared by all Contexts related to this virtual host.  By
             default (when using FileLogger), log files are created in the "logs"
             directory relative to $CATALINA_HOME.  If you wish, you can specify
             a different directory with the "directory" attribute.  Specify either a
             relative (to $CATALINA_HOME) or absolute path to the desired
             directory.-->
        <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." suffix=".txt"
	        timestamp="true"/>

        <!-- Define properties for each web application.  This is only needed
             if you want to set non-default properties, or have web application
             document roots in places other than the virtual host's appBase
             directory.  -->

        <!-- Tomcat Root Context -->
          <Context path="" docBase="ROOT" debug="0"/>

      </Host>

    </Engine>

  </Service>

</Server>
 
Step 5. Change the "<url-pattern>/opencms/*</url-pattern>" in /cms/WEB-INF/web.xml to "<url-pattern>/en/*</url-pattern>".

Step 6. Change the "url_prefix_http=/${WEB_APP_NAME}/opencms" in opencms.properties to "url_prefix_http=/${WEB_APP_NAME}/en".

Step 7. Add following in httpd.conf:
LoadModule jk2_module modules/mod_jk2.so

<IfModule mod_jk2.c>
    #-----------------------------------------------
    # Where to find the workers2.properties file
    #-----------------------------------------------
    #
    JkSet config.file /apache2-path/conf/workers2.properties
</IfModule>

Step 8. Create and edit /apache2-path/conf/workers2.properties:
# Define the communication channel 
[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
tomcatId=localhost:8009

# Map the Tomcat examples webapp to the Web server uri space
[uri:/examples/*]

[uri:/cms/*]

Step 9. Restart Apache and Tomcat.

Step 10. Type http://yourServerName/cms/en/ in your explorer. If you see the OpenCMS welcome page, congratulations! Everything is fine. If not, pls check whether there's any misspelling.

Step 11. If you find any 404 error and you are sure the file should be there, try to add alias path in your httpd.conf.

Regards,

Shi Yusen/Langhua

-----????-----
???: Oliver Pereira [mailto:Oliver.Pereira at dna.co.uk]
????: 2004?11?20? 1:23
???: opencms-dev at opencms.org
??: [opencms-dev] Proxy Problems


Hi, 
I have the following configuration setup in my apache httpd.conf (this change is to remove the /opencms/opencms/ from the URL).
Everything works fine except one problem and i.e. if I uncomment the ProxyPass from the configuration as shown below it removes the opencms from the URL but then the Login doesn't work. But with the current configuration the Login works but opencms is still part of the URL.
I am using Apache 2.0, Tomcat 5.0 and OpenCMS 6.0 apha 2 
Any inputs would be highly appreciated 
 <VirtualHost www.alkakon.net> 
     ServerName www.alkakon.net 
     DocumentRoot "C:/tomcat50/webapps/" 
     ErrorLog logs/error.log 


    SetEnvIf Request_URI "\/opencms\/*" redirect 
   CustomLog logs/localhost-access.log common env=!redirect 
     #ProxyPass         /opencms/         ! <=== uncommenting this line removes the opencms from the URL but then the login does not work
     RedirectPermanent /opencms/        http://www.alkakon.net/ 
     ProxyPass         /resources/       http://127.0.0.1:8082/resources/ 
     ProxyPass         /export/          http://127.0.0.1:8082/export/ 
     ProxyPass         /opencms/          http://127.0.0.1:8082/opencms/ 
     ProxyPass         /                 http://127.0.0.1:8082/opencms/ 
     ProxyPassReverse  /                 http://127.0.0.1:8082/opencms/ 
 </VirtualHost> 
Regards, 
Oliver 


More information about the opencms-dev mailing list