Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 '10 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 '10 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 '10 at 20:50
add comment

migrated from stackoverflow.com Jan 6 '10 at 20:57

This question came from our site for professional and enthusiast programmers.

1 Answer

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>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.