Question

I am trying to get Apache to forward requests to the examples that come with Tomcat. I did it once on another machine a few months ago, but on this new server I am stump.

Tomcat is running fine, localhost:8080 loads the default homepage and localhost:8080/examples/ displays the example page. But when I drop the 8080 and use port 80 on the apache server, it simply gives me a 404.

What is really bugging me is the lack of any log info on why. I am using the stock httpd-jk.conf with this added:

JkMount     /examples/*             worker1

Then this is my workers.properties:

worker.list=jk-status
worker.jk-status.type=status
worker.jk-status.read_only=true

worker.list=jk-manager
worker.jk-manager.type=status

worker.list=worker1
worker.worker1.reference=worker.template
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.activation=A

worker.template.type=ajp13

worker.template.socket_connect_timeout=5000

worker.template.socket_keepalive=true
worker.template.ping_mode=A
worker.template.ping_timeout=10000
worker.template.connection_pool_minsize=0
worker.template.connection_pool_timeout=600
worker.template.reply_timeout=300000
worker.template.recovery_options=3

And the Tomcat server.xml:

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>
Was it helpful?

Solution

Answering with a checklist;

  • Are you certain port 80 is served by the Apache you expect - are your "404" responses showing in the access logs of that Apache instance
  • are you certain your mod_jk module is being loaded (see Apache logs, or use one of the Apache status page views to verify); if the module was not loaded, the JK configuration section would be silently ignored
  • are you certain your workers.properties is being found (Still, see Apache logs; you might also wish to raise the JkLogLevel in httpd.conf to trace for the time being; also, make sure you know where your JkLogFile is located)

Then about the SSL issue; mod_jk and mod_proxy_ajp should both work. If you just want basic "server-side SSL", and are not working with client certificates, then everything will be handled by your Apache httpd. If, on the other hand, you'll be doing client authentication using SSL client certificates, then I think there's another SO posting rather relevant to that use case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top