I have a few Tomcat installs where there is only a single main application on them (in addition to things like Manager). Other than just changing the default Tomcat homepage to include a redirect to the app, is there a better way? Or, one better, how can I map http://domain.com:8080/app to just http://domain.com:8080 and leave the other apps (like Manager) alone?
Install the app to be the
ROOT
context.That could be done by:
ROOT.war
,webapps/ROOT
directory,"/"
via the Tomcat manager,<Context path="/" docBase="${catalina.home}/webapps/app"/>
I pretty much always stick an Apache in front of a Tomcat and connect via AJP (either mod_proxy_ajp or mod_jk) because Tomcat is so incredibly inefficient at serving static content and because of the exact problem you describe. Also, by sticking a front end on, you can protect /manager and any other apps with rewrite rules. /manager is also a frequent source of attack, and this technique prevents the outside world from reaching it completely.
To create a redirect like you are describing, create a rewrite rule to the effect of:
I'm sure something like this can be done at the Tomcat layer, but my preference is to keep the Tomcat portable and simple and create any rules like this at the Apache level.
If you do this, don't forget to JkUnmount or exclude via proxy_ajp your static content so that it is served from the Apache.