You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Williams, Allen" <aw...@harris.com> on 2004/11/05 19:48:38 UTC

[users@httpd] Connecting Apache and Tomcat

I am (have been for some time) having a very difficult time doing something that
should be easy and straightforward- connecting Apache to Tomcat and having
Apache serve static contact and Tomcat serve dynamic content.  My directory
structures are rather convoluted, but came mainly from the installation.  I'm
certainly willing to simplify them if it would help, but I can't figure out why
it doesn't work.  Every time I try http://localhost/examples/ I get the
directory listing (under Apache, not under Tomcat), but when clicking on the
entries, ultimately get a 404-File not Found error, when Apache should be (I
think) looking at the directory and passing it off to Tomcat.

-------------------------------------------------------------------
Webapps directory structure: /usr/share/tomcat4/server/webapps/...
	...examples
	...admin
	...manager
-------------------------------------------------------------------
Apache directory structure:
/var/www/...
	...examples
-------------------------------------------------------------------
workers2.properties snippet:

[uri:/admin/*]
info=Tomcat HTML based administration web application.
debug=5
context="admin"
worker=ajp13:localhost:8009

[uri:/manager/*]
info=A scriptable management web application for the Tomcat Web Server. debug=5
context="manager" worker=ajp13:localhost:8009

[uri:/examples/*]
info=tomcat Examples.
debug=5
context="examples"
worker=ajp13:localhost:8009
-------------------------------------------------------------------
server.xml snippet:

      <Host name="localhost" debug="5" appBase="webapps" 
            unpackWARs="true" autoDeploy="true">
-------------------------------------------------------------------
CATALINA_BASE directory structure:
/var/lib/tomcat4/...
	...webapps/...
		...admin.xml
		...manager.xml
		...examples.xml
-------------------------------------------------------------------
Contents of, for example, admin.xml:

<!--
    Context configuration file for the Tomcat Administration Web App
-->

<Context path="/admin" docBase="/usr/share/tomcat4/server/webapps/admin"
         debug="5" privileged="true" allowLinking="true">

  <!-- make symlinks work in Tomcat 4.1 -->
  <Resources className="org.apache.naming.resources.FileDirContext"
             allowLinking="true" />

  <!-- Uncomment this Valve to limit access to the Admin app to localhost
       for obvious security reasons. Allow may be a comma-separated list of
       hosts (or even regular expressions).
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127.0.0.1"/>
  -->

  <Logger className="org.apache.catalina.logger.FileLogger"
          prefix="localhost_admin_" suffix=".log" timestamp="true"/>

</Context>
-------------------------------------------------------------------

If someone could *possibly* give me a hand here, I sure would appreciate it.

TIA,
anw

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Connecting Apache and Tomcat

Posted by beyaNet <an...@jibeya.com>.
Alan,
try this:

1. http.conf

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule jk2_module modules/mod_jk2.so

RewriteEngine on
RewriteRule (.*)\.(xml|xsl|kont|jx|xsp|css|js|mp3|m3u|jpg)$ 
http://localhost:8080/cocoon/$1.$2 [P,L]
ProxyPassReverse / http://localhost:8080/


2. workers2.properties

[logger]
level=DEBUG

[config:]
file=${serverRoot}/conf/workers2.properties
debug=0
debugEnv=0

[uriMap:]
info=Maps the requests. Options: debug
debug=0

[shm:]
info=Scoreboard. Required for reconfiguration and status with 
multiprocess servers
file=${serverRoot}/logs/jk2.shm
size=1048576
debug=0
disabled=0

[workerEnv:]
info=Global server options
timing=1
debug=0
# Default Native Logger (apache2 or win32 )
# can be overriden to a file logger, useful
# when tracing win32 related issues
#logger=logger.file:0


# Log file, replace APACHE_HOME by your Apache installation directory
[shm]
file=${serverRoot}/logs/mod_jk.log
size=1048576

# The load balancer
[lb:lb]
info=Default load balancer.
debug=0

[lb:lb_1]
info=A second load balancer.
debug=0

# Server 1, override port and host.
[channel.socket:server1:8009]
port=8009
host=localhost

# Server 2, override port and host.
[channel.socket:server2:8009]
port=8009
host=localhost

# define worker for server 1
[ajp13:server1:8009]
channel=channel.socket:server1:8009
group=lb

# define worker for server 2
[ajp13:server2:8009]
channel=channel.socket:server2:8009
group=lb

# Uri mapping
[uri:/your-cocoon-application name/*]
group=lb

3. make cocoon your root application in whatever container it is you 
are using

4. http://www.mysite.com/ - will give you index.html on Apache
5. http://www.mysite.com/somefilename.xml - will jump you straight into 
your application. Hence no need for 
http://www.mysite.com:8080/cocoon/your-cocoon-application 
name/somefilename.xml


regards


Andrew
On 5 Nov 2004, at 18:48, Williams, Allen wrote:

> I am (have been for some time) having a very difficult time doing 
> something that
> should be easy and straightforward- connecting Apache to Tomcat and 
> having
> Apache serve static contact and Tomcat serve dynamic content.  My 
> directory
> structures are rather convoluted, but came mainly from the 
> installation.  I'm
> certainly willing to simplify them if it would help, but I can't 
> figure out why
> it doesn't work.  Every time I try http://localhost/examples/ I get the
> directory listing (under Apache, not under Tomcat), but when clicking 
> on the
> entries, ultimately get a 404-File not Found error, when Apache should 
> be (I
> think) looking at the directory and passing it off to Tomcat.
>
> -------------------------------------------------------------------
> Webapps directory structure: /usr/share/tomcat4/server/webapps/...
> 	...examples
> 	...admin
> 	...manager
> -------------------------------------------------------------------
> Apache directory structure:
> /var/www/...
> 	...examples
> -------------------------------------------------------------------
> workers2.properties snippet:
>
> [uri:/admin/*]
> info=Tomcat HTML based administration web application.
> debug=5
> context="admin"
> worker=ajp13:localhost:8009
>
> [uri:/manager/*]
> info=A scriptable management web application for the Tomcat Web 
> Server. debug=5
> context="manager" worker=ajp13:localhost:8009
>
> [uri:/examples/*]
> info=tomcat Examples.
> debug=5
> context="examples"
> worker=ajp13:localhost:8009
> -------------------------------------------------------------------
> server.xml snippet:
>
>       <Host name="localhost" debug="5" appBase="webapps"
>             unpackWARs="true" autoDeploy="true">
> -------------------------------------------------------------------
> CATALINA_BASE directory structure:
> /var/lib/tomcat4/...
> 	...webapps/...
> 		...admin.xml
> 		...manager.xml
> 		...examples.xml
> -------------------------------------------------------------------
> Contents of, for example, admin.xml:
>
> <!--
>     Context configuration file for the Tomcat Administration Web App
> -->
>
> <Context path="/admin" 
> docBase="/usr/share/tomcat4/server/webapps/admin"
>          debug="5" privileged="true" allowLinking="true">
>
>   <!-- make symlinks work in Tomcat 4.1 -->
>   <Resources className="org.apache.naming.resources.FileDirContext"
>              allowLinking="true" />
>
>   <!-- Uncomment this Valve to limit access to the Admin app to 
> localhost
>        for obvious security reasons. Allow may be a comma-separated 
> list of
>        hosts (or even regular expressions).
>   <Valve className="org.apache.catalina.valves.RemoteAddrValve"
>          allow="127.0.0.1"/>
>   -->
>
>   <Logger className="org.apache.catalina.logger.FileLogger"
>           prefix="localhost_admin_" suffix=".log" timestamp="true"/>
>
> </Context>
> -------------------------------------------------------------------
>
> If someone could *possibly* give me a hand here, I sure would 
> appreciate it.
>
> TIA,
> anw
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server 
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>