aspose file tools*
The moose likes Tomcat and the fly likes Yet another Tomcat port question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Yet another Tomcat port question" Watch "Yet another Tomcat port question" New topic
Author

Yet another Tomcat port question

Michael MacEachran
Greenhorn

Joined: Dec 15, 2009
Posts: 11
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 :

localhost:8080/myapp
localhost:8080/yourapp
localhost:8080/everyonesapp

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"
connectionTimeout="20000"
redirectPort="8443"
appBase="/webapps/myapp" />
<Connector port="8081" protocol="HTTP/1.1" URIEncoding="UTF-8"
connectionTimeout="20000"
redirectPort="8444"
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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Yet another Tomcat port question