Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Yet another Tomcat port question  RSS feed

Michael MacEachran
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have searched through all the past post and have not found exactly what I need so here it goes:

I have working several webapps under the webapp directory such that :


all works fine under the same tomcat instance.

Now management has spoken and it MUST be this way:

localhost:8080/ (is the home of myapp) aka /webapps/myapp/index.jsp
localhost:8081/ (is the home of yourapp) aka /webapps/yourapp/index.jsp
localhost:8082/ (is the home of everyonesapp) aka /webapps/everyonesapp/index.jsp

all under the same tomcat instance

I tried to just play with the connector such that:

<Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8"
appBase="/webapps/myapp" />
<Connector port="8081" protocol="HTTP/1.1" URIEncoding="UTF-8"
appBase="/webapps/yourapp" />

etc... but that did not work. I suspect that I must also change my myapp.xml in /conf/Catalina/localhost/myapp but I do not know where to begin.

thank you in advance for any help
Tim Holloway
Posts: 18705
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Congratulations, Dilbert! Have they received their "Best Management" trophies from Catbert yet?

There are several ways to handle this. One is to setup port forwarding so that while the external port ID varies, they all get rerouted to port 8080 in the server OS. If they hadn't decreed that the context names must be removed, some OS's could do that using firewall rules, but since you actually need URL rewriting, you'd need a proxy or Apache+mod_rewrite.

The other (and MUCH uglier) way is to setup multiple virtual hosts. You can't just add Connector elements, you actually have to define new Host Elements, and maybe even Engine elements (I'd have to RTFM to remember). And did anyone think to check to see if HTTPS is going to be required? That's another set of ports.

Neither TCP/IP nor J2EE nor Tomcat were intended to be used this way. Otherwise you'd be specifying port numbers in URLs all day long. Yes, you can do it, but it makes life much more complicated for a questionable gain. And it's going to take considerable time and effort (= money) to set up and support.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!