You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "J. Zimmerman" <jo...@gmail.com> on 2009/05/22 04:28:29 UTC

Apache 2.2 to Tomcat 6 via proxy_ajp

I am just getting started with Tomcat and have been asked to take on the
administration of our Tomcat servers at our college.  I am not one of the
developers, just the administrator.  So far everything has gone pretty
smoothly except for getting everything to run proxied via Apache (at least
the way we would like it).

Our requirement is for Tomcat to deliver the application through
http://hostname:8080/appname and/or ajp://hostname:8009/appname.  This
happens by default and works well.  However, we want end users to access the
applications via port 443 or 80 and we are doing this via Apache.  I can
make this work via proxy_ajp and proxy_http so that something like
http://hostname/appname works just fine.

The wrench in the works is that we want to do virtual hosting through Apache
and not have the appname appended to it.  The Apache virtual hosted URL's
will be the ones exposed to the public.

For example if we developed an application called "mycoolapp" and we were
deploying it at a website of the same name we would want the application to
run at http://mycoolapp.com and not http://mycoolapp.com/mycoolapp.

I have hacked together several different configs suggested through many
different pieces of documentation and forums, but just can't seem to get it.

Our setup is as follows.....

Server: Ubuntu 8.04 (all updates)
Java: Latest JDK download from Sun
Tomcat: Latest version 6 official download (configs are near defaults, I
have revereted to the default server.xml)
Apache: Latest version 2.2 via Ubuntu repositories.  proxy_ajp, proxy_http,
and rewrite enabled.

If anyone has suggestions or a working example any help is greatly
appreciated.

Re: Apache 2.2 to Tomcat 6 via proxy_ajp

Posted by Mark Thomas <ma...@apache.org>.
J. Zimmerman wrote:
> I am just getting started with Tomcat and have been asked to take on the
> administration of our Tomcat servers at our college.  I am not one of the
> developers, just the administrator.  So far everything has gone pretty
> smoothly except for getting everything to run proxied via Apache (at least
> the way we would like it).
> 
> Our requirement is for Tomcat to deliver the application through
> http://hostname:8080/appname and/or ajp://hostname:8009/appname.  This
> happens by default and works well.  However, we want end users to access the
> applications via port 443 or 80 and we are doing this via Apache.  I can
> make this work via proxy_ajp and proxy_http so that something like
> http://hostname/appname works just fine.
> 
> The wrench in the works is that we want to do virtual hosting through Apache
> and not have the appname appended to it.  The Apache virtual hosted URL's
> will be the ones exposed to the public.
> 
> For example if we developed an application called "mycoolapp" and we were
> deploying it at a website of the same name we would want the application to
> run at http://mycoolapp.com and not http://mycoolapp.com/mycoolapp.

Inside your virtual host, something like:

ProxyPass / http://tomcat.host:8080/mycoolapp/
ProxyPassReverse / http://tomcat.host:8080/mycoolapp/

should do the trick.

What have you tried and what, exactly, didn't work?

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Apache 2.2 to Tomcat 6 via proxy_ajp

Posted by "J. Zimmerman" <jo...@gmail.com>.
Thanks for all of the replies.  I had tried most of the suggestions
previously, but things were still not working the way I wanted.
Specifically I could get it to work if I was willing to using
http://domain.com/appname, but not just http://domain.com/.

I had seen the Tomcat virtual hosting documentation, but overall we kind of
run a hybrid apache2 / apache tomcat environment so I needed to front end
everything through Apache2 mod_proxy_ajp.

It turns out I was *really* close and technically it was working.  The
Tomcat application (which is an Apache Wicket) was doing a redirect that
made a working config seem broken.

So here is my working (deemed working without major testing) for this
specific application.  Others may not require the Rewrite rule or may
require a different rewrite rule.

<VirtualHost *:80>
>     ServerName  testproxy.domain.com
>
>     RewriteEngine On
>     RewriteRule ^/appname/(.*)$ http://testproxy.domain.com/$1 [L]
>
>     ProxyPreserveHost   On
>
>     ProxyPass / ajp://localhost:8009/appname/
>     ProxyPassReverse / ajp://localhost:8009/appname/
>
>     <Proxy *>
>         Order allow,deny
>         Allow from all
>     </Proxy>
>
>     ErrorLog /var/log/apache2/testproxy.domain.com-error.log
>
>     # Possible values include: debug, info, notice, warn, error, crit,
>     # alert, emerg.
>     LogLevel warn
>
>     CustomLog /var/log/apache2/testproxy.domain.com-access.log combined
>     ServerSignature Off
> </VirtualHost>
>

Thanks to everyone who read or responded to this thread.

Re: Apache 2.2 to Tomcat 6 via proxy_ajp

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

On 5/21/2009 11:43 PM, Caldarale, Charles R wrote:
>> From: J. Zimmerman [mailto:john.zimm@gmail.com] Subject: Apache 2.2
>> to Tomcat 6 via proxy_ajp
>> 
>> The wrench in the works is that we want to do virtual hosting
>> through Apache and not have the appname appended to it.  The Apache
>> virtual hosted URL's will be the ones exposed to the public.
> 
> Do you really need httpd in the game?  Is it providing any useful
> service (e.g., PHP)?  If not, remove it and simplify your life.

+1

> If you must have httpd in the picture, mod_rewrite might help if the
> Tomcat virtual hosting is insufficient (but perhaps you've already
> tried that).

I'm not sure mod_rewrite is necessary. Instead, you can do something
like this:

<VirtualHost *:80>
  ServerName mycoolapp.com


  ProxyPass / ajp://host:8009/mycoolapp
</VirtualHost>

You could also get away with:

<VirtualHost *:80>
  ServerName mycoolapp.com


  ProxyPass / ajp://host:8009/
</VirtualHost>

...if you deploy mycoolapp as the ROOT context.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkoWp10ACgkQ9CaO5/Lv0PARvQCfVLmzTfeXl7W3xqEc8LOsMXu7
6voAoJizHcvoTPBCgJB9JSqmTeJFSPv2
=2zTC
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Apache 2.2 to Tomcat 6 via proxy_ajp

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: J. Zimmerman [mailto:john.zimm@gmail.com]
> Subject: Apache 2.2 to Tomcat 6 via proxy_ajp
> 
> The wrench in the works is that we want to do virtual hosting through
> Apache and not have the appname appended to it.  The Apache virtual 
> hosted URL's will be the ones exposed to the public.

Do you really need httpd in the game?  Is it providing any useful service (e.g., PHP)?  If not, remove it and simplify your life.

Look here for how to do virtual hosting in Tomcat:
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html

If you must have httpd in the picture, mod_rewrite might help if the Tomcat virtual hosting is insufficient (but perhaps you've already tried that).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Apache 2.2 to Tomcat 6 via proxy_ajp

Posted by Jim Jagielski <ji...@jaguNET.com>.
On May 21, 2009, at 10:28 PM, J. Zimmerman wrote:

> I am just getting started with Tomcat and have been asked to take on  
> the
> administration of our Tomcat servers at our college.  I am not one  
> of the
> developers, just the administrator.  So far everything has gone pretty
> smoothly except for getting everything to run proxied via Apache (at  
> least
> the way we would like it).
>
> Our requirement is for Tomcat to deliver the application through
> http://hostname:8080/appname and/or ajp://hostname:8009/appname.  This
> happens by default and works well.  However, we want end users to  
> access the
> applications via port 443 or 80 and we are doing this via Apache.  I  
> can
> make this work via proxy_ajp and proxy_http so that something like
> http://hostname/appname works just fine.
>
> The wrench in the works is that we want to do virtual hosting  
> through Apache
> and not have the appname appended to it.  The Apache virtual hosted  
> URL's
> will be the ones exposed to the public.
>
> For example if we developed an application called "mycoolapp" and we  
> were
> deploying it at a website of the same name we would want the  
> application to
> run at http://mycoolapp.com and not http://mycoolapp.com/mycoolapp.
>
> I have hacked together several different configs suggested through  
> many
> different pieces of documentation and forums, but just can't seem to  
> get it.
>
> Our setup is as follows.....
>
> Server: Ubuntu 8.04 (all updates)
> Java: Latest JDK download from Sun
> Tomcat: Latest version 6 official download (configs are near  
> defaults, I
> have revereted to the default server.xml)
> Apache: Latest version 2.2 via Ubuntu repositories.  proxy_ajp,  
> proxy_http,
> and rewrite enabled.
>
> If anyone has suggestions or a working example any help is greatly
> appreciated.

ProxyPass / http://hostname:8080/mycoolapp

     -or-

ProxyPass / ajp://hostname:8080/mycoolapp

Assuming hostname:8080 is the Tomcat server

No need for rewrite at all.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org