Unfortunately I don't know anything about that apache-proxy stuff. However, I had a similar problem and my workaround may help you to solve your issue.
I fully integrated tomcat into apache using mod-jk
. Assuming you're using a Debian-based distro just install libapache2-mod-jk
and configure the module in /etc/libapache2-mod-jk/workers.properties
. You may need something like this:
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
These parameters define the connection between apache and tomcat. I told tomcat to only listen to 127.0.0.1
. But it should be fine to configure the module to speak to another IP and/or a different port if you need a standalone tomcat installation available without apache.
Next step: Open /etc/apache2/mods-available/jk.conf
and make sure that apache reads these properties:
JkWorkersFile /etc/libapache2-mod-jk/workers.properties
If that is done, the communication between apache and tomcat should work. Now you can create some hosts forwarding their requests to tomcat:
<VirtualHost *:80>
[...]
ServerName your.host.tld
[...]
RewriteEngine on
RewriteRule ^/(.*)$ /YourContext/$1 [L,PT]
JkMount /* ajp13_worker
[...]
</VirtualHost>
This virtual host will forward each request to the context YourContext
at tomcat. ajp13_worker
is the worker-definition as previously configured in /etc/libapache2-mod-jk/workers.properties
(of course you can configure multiple workers for different IPs/ports) and the RewriteRule
rewrites the query to prefix it with YourContext
. So you also need the rewrite module, if it's not already enabled. Enable the modules and this host:
a2enmod jk
a2enmod rewrite
a2ensite 007-what-ever-host
service apache2 restart
service tomcat7 restart
and go for http://your.host.tld/abc?some=query
. You'll hopefully end up with the same result as if you call http://your.host.tld:8080/YourContext/abc?some=query
.
Hope that helps ;-)