Problem description: You want to server multiple web applications with one Tomcat instance. The brute force variant is to just “rewrite” or ProxyPass the request from e.g. to the local tomcat with localhost:8080/myhost. But this leads to context urls of ressources in the served html pages. You can either deploy you webapp in the ROOT context (but there is just ONE ROOT context, so this does not work). So let us use virtual hosts on both, the apache webserver and the tomcat servlet container.

create a app location in $CATALINA_HOME

deploy the webapp in ROOT context

edit server.xml according

in Tomcat server.xml

<Engine name=“Catalina” defaultHost=“”>
<Host name=“” appBase=“”>

edit Apache config according:

In Apache conf

<VirtualHost *>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
    ProxyPass /
ProxyPassReverse /
<Location />
Order allow,deny
Allow from all

and in /etc/hosts   localhost

restart tomcat
restart apache

that’s it :-)

Interested in Cloud or Chef Trainings? Have a look at our Commandemy Trainings page. Need help migrating to the cloud? Check out Infralovers.

comments powered by Disqus
Blog Tags