2

I am running a web app on Tomcat at the following location on my server.

/var/tomcat/webapps/SoccerApp

I am looking to update the Tomcat httpd.conf file with the following virtual host...

<VirtualHost *:80>
DocumentRoot /var/tomcat/webapps/SoccerApp/MyTeam
ServerName www.mysoccerapp.com
</VirtualHost> 

This gives me a 404 error as the directory MyTeam does not exist. However my application behaves in a way that it uses this URL directory as the name of the soccer team for which to display data, so it will never be a physical folder on the server. None the less, I would like www.mysoccerapp.com to resolve to webapps/SoccerApp/MyTeam, even though the directory isnt there.

does this make any sense? Any ideas on how to get this working. At the end of the day, i want to do the following...

www.teamone.com -> runs /webapps/SoccerApp/TeamOne
www.teamone.com -> runs /webapps/SoccerApp/TeamTwo

...where TeamOne and TeamTwo are not physical directories, but merely processed by my SoccerApp application as the current soccer team to display data for.

Many many thanks!

Dave.

3
  • I think you have things mixed up, at least no tomcat server I have seen has a httpd.conf with a DocumentRoot. That's something you will find in the configuration of the Apache httpd server.
    – Fredrik
    Jan 6, 2010 at 19:07
  • So... The big question is, are you looking for how to configure namebased virtual hosts in Apache httpd with a connected tomcat or in Tomcat as a stand alone web server?
    – Fredrik
    Jan 6, 2010 at 19:09
  • Assuming that you're trying to use apache httpd to reverse proxy to multiple tomcat webapps, see: serverfault.com/questions/80338/… (windows specific, but includes good info on configuring apache2 for reverse proxy).
    – nojo
    Jan 6, 2010 at 20:50

1 Answer 1

1

You need to use mod_proxy to set up a reverse proxy. You can then point the two URLs to the web apps that are handling the sites.

The Apache docs do a pretty good job of explaining, but here is the relevant portion from one of our sites:

 ProxyRequests off
        <Location /app>
                ProxyPass https://www.ourwebsite.com/
                ProxyHTMLURLMap https://www.ourwebsite.com /app
                ProxyPassReverse https://www.ourwebsite.com/
                SetOutputFilter  proxy-html
                ProxyHTMLURLMap  /      /app/
                ProxyHTMLURLMap  /app  /app
                RequestHeader    unset  Accept-Encoding
        </Location>

You must log in to answer this question.