You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Je suis la poubelle <la...@gmail.com> on 2009/03/19 14:16:49 UTC

How to make Tomcat serve/listen to one more port?

     (I've searched through the archive back to November 2008 but it seems
like this question hasn't been asked, so I take the risk to ask it :) )

     My short question is:  How to make Tomcat serve HTTP to one more port
(in Windows Server 2003)?

     Tomcat listens to 8080 (or 80) for HTTP.  Is it possible to make it
listen to one more port, eg 12345, to serve HTTP?  And by this, I mean it's
suppose to serve a totally different web site at this new port.

     If someone's going to ask me "why": the reason behind is that VMWare
Server 2 is using Tomcat to serve its web application.  I need to create my
own portal page to give my users more informations about the server (because
VMWare's website is purely functional).  Right now, my own solution is
install IIS6 (as I'm using Windows Server 2003) and make it serve the page.
But I think it's quite a waste of resource to run an additional IIS6; wonder
why I can't make Tomcat to serve that page.

     Yes, I had asked this question in VMWare's forum, but nobody knows the
answer.  So I think it's better asked in this Tomcat mailing-list.

Re: How to make Tomcat serve/listen to one more port?

Posted by Je suis la poubelle <la...@gmail.com>.
On Fri, Mar 20, 2009 at 7:04 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Je suis la poubelle [mailto:lapsap7@gmail.com]
> > Subject: Re: How to make Tomcat serve/listen to one more port?
>
> > Unfortunately, I really need (b).  It's very easy to do
> > (b) in IIS6, but it doesn't seem to be the case in Tomcat
> > (no flame intended, just a pure comparison :p )
>
> I already told you how: create a second <Service>, and put the second
> <Connector> and another <Host> inside that.
>

      OK, thanks, I'll have a try :)

RE: How to make Tomcat serve/listen to one more port?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Je suis la poubelle [mailto:lapsap7@gmail.com] 
> Subject: Re: How to make Tomcat serve/listen to one more port?

> Unfortunately, I really need (b).  It's very easy to do 
> (b) in IIS6, but it doesn't seem to be the case in Tomcat
> (no flame intended, just a pure comparison :p )

I already told you how: create a second <Service>, and put the second <Connector> and another <Host> inside that.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to make Tomcat serve/listen to one more port?

Posted by Je suis la poubelle <la...@gmail.com>.
On Tue, Mar 24, 2009 at 12:38 PM, Je suis la poubelle <la...@gmail.com>wrote:

> [snipped]
>
>      Good luck to all.
>

And of course, restart Tomcat service at the end ;)

Re: How to make Tomcat serve/listen to one more port?

Posted by Je suis la poubelle <la...@gmail.com>.
On Fri, Mar 20, 2009 at 7:14 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Caldarale, Charles R
> > Subject: RE: How to make Tomcat serve/listen to one more port?
> >
> > I already told you how: create a second <Service>, and put
> > the second <Connector> and another <Host> inside that.
>
> If that's not clear, send me your server.xml, and I'll update it.  Should
> take less than a minute.


     OK, I've done it and it's working.  So for the record and for those who
are searching how to do the same thing as me, I write down the procedure
here.  Please correct me if I forgot anything.

     First, stop Tomcat service.  Then in the conf/server.xml, add the
following new "Service" element:

  <Service name="NewWebSiteAtAnotherPort">
      <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" />

      <Engine name="NewWebSiteAtAnotherPort" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <Host name="localhost"  appBase="NewWebSite"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      </Host>
    </Engine>
  </Service>

     Things to take care:
* <Service name=...  must be unique, with respect to those existent
"Service" elements
* <Connector port=... the new port number (of course!)
* <Engine name=...   must be unique wrt to those existent "Engine" elements
* <Host appBase=...  name of the new directory, NewWebSite here
* Then create a new webapp directory in the same parent directory as
"webapps".  The name must match what's written in appBase attribute.  Here I
call the new directory "NewWebSite".

     I'm not sure if the "Realm" element is really necessary.  So it's just
a copy-n-paste from the default one.  And I'm esp not sure if the
"resourceName" should be changed.  Here, I didn't change it but my new
website is working, so I suppose it's OK like this.

     Good luck to all.

RE: How to make Tomcat serve/listen to one more port?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Caldarale, Charles R 
> Subject: RE: How to make Tomcat serve/listen to one more port?
> 
> I already told you how: create a second <Service>, and put 
> the second <Connector> and another <Host> inside that.

If that's not clear, send me your server.xml, and I'll update it.  Should take less than a minute.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to make Tomcat serve/listen to one more port?

Posted by Je suis la poubelle <la...@gmail.com>.
On Fri, Mar 20, 2009 at 2:57 PM, André Warnier <aw...@ice-sa.com> wrote:

> Hi poubelle.
> (J'ai toujours rêvé de pouvoir écrire ca sans être impoli..).


OT:   :D Parce que cette adresse-ci est créée pour recevoir des cochonneries
comme les pubs, les listes de diffusions, etc.  C'est pas mon adresse perso
:)

     Translation: "Je suis la poubelle" means "I'm the trashcan" in French.
This isn't my personal e-address; just a mailbox to receive stuffs like ads,
mailing-lists, etc.


> Je suis la poubelle wrote:
>
>>
>>     Currently, I access the Tomcat's default website using an URL like
>> this:
>> http://myservername:x/....
>>
>>     All I want to do is to have another website using an URL like this:
>> http://myservername:y/....
>>
>>     TIA
>>
>>  Starting from the beginning :
> What you are describing above is feasible, but not very easily.
> That is because generally what people want, is to do this :
> a)
> http://myservername1/
> http://myservername2/
> (and get a different application when they access "myservername1" than when
> they access "myservername2")
> and not
> b)
> http://myservername:8080/
> http://myservername:8081/
> (and get a different application when they access "myservername:8080" than
> when they access "myservername:8081")
>
> (a) is easy to do with Tomcat, (b) is more complicated.
> So tell us first if (a) would be fine, because then we can tell you how-to,
> in less lines than would be needed for (b).


     Unfortunately, I really need (b).  It's very easy to do (b) in IIS6,
but it doesn't seem to be the case in Tomcat (no flame intended, just a pure
comparison :p )

Re: How to make Tomcat serve/listen to one more port?

Posted by André Warnier <aw...@ice-sa.com>.
Hi poubelle.
(J'ai toujours rêvé de pouvoir écrire ca sans être impoli..).

Je suis la poubelle wrote:
> 
>      Currently, I access the Tomcat's default website using an URL like
> this:
> http://myservername:x/....
> 
>      All I want to do is to have another website using an URL like this:
> http://myservername:y/....
> 
>      TIA
> 
Starting from the beginning :
What you are describing above is feasible, but not very easily.
That is because generally what people want, is to do this :
a)
http://myservername1/
http://myservername2/
(and get a different application when they access "myservername1" than 
when they access "myservername2")
and not
b)
http://myservername:8080/
http://myservername:8081/
(and get a different application when they access "myservername:8080" 
than when they access "myservername:8081")

(a) is easy to do with Tomcat, (b) is more complicated.
So tell us first if (a) would be fine, because then we can tell you 
how-to, in less lines than would be needed for (b).




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to make Tomcat serve/listen to one more port?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Je suis la poubelle [mailto:lapsap7@gmail.com] 
> Subject: Re: How to make Tomcat serve/listen to one more port?
> 
> I can't see how a host can use such and such connector!? 

You can't, nor do you need to.  All <Host> elements share all <Connector>s within a <Service>.  The content of the URL will select the proper <Host>.  As I said before, you don't really need to separate the web sites by port number; one <Connector> will suffice.  You *must* however, have different web site names (even if they resolve to the same IP address) in order to allow the differentiation to work.

If you insist on differentiating by port number alone, you have to create multiple <Service> elements, each with their own <Connector>, <Engine>, and <Host> elements.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to make Tomcat serve/listen to one more port?

Posted by Je suis la poubelle <la...@gmail.com>.
     I must admit that I'm lost, despite hours of readings....  I have to
add that Tomcat documentation is never very clear and comprehensible.

     I can't see how a host can use such and such connector!?  I mean, the
connector's doc at
http://tomcat.apache.org/tomcat-6.0-doc/config/http.htmldoesn't tell
me which host I could attach it to.  And host's doc at
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html doesn't
give any clue which connector to use.

     And I've a doubt that virtual hosting is actually what I was looking.

     Currently, I access the Tomcat's default website using an URL like
this:
http://myservername:x/....

     All I want to do is to have another website using an URL like this:
http://myservername:y/....

     TIA

On Thu, Mar 19, 2009 at 6:18 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> > Subject: RE: How to make Tomcat serve/listen to one more port?
> >
> > Correct; the <Host> element is equivalent to a web site, the
> > <Connector>s just feed the <Host>s, based on the name and <Alias>.
>
> Note that you don't really need multiple <Connector> elements to support
> multiple <Host>s; one <Connector> will suffice, and it will route requests
> to the appropriate <Host> based on the URL.
>
>  - Chuck
>

RE: How to make Tomcat serve/listen to one more port?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
> Subject: RE: How to make Tomcat serve/listen to one more port?
> 
> Correct; the <Host> element is equivalent to a web site, the 
> <Connector>s just feed the <Host>s, based on the name and <Alias>.

Note that you don't really need multiple <Connector> elements to support multiple <Host>s; one <Connector> will suffice, and it will route requests to the appropriate <Host> based on the URL.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to make Tomcat serve/listen to one more port?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Je suis la poubelle [mailto:lapsap7@gmail.com] 
> Subject: Re: How to make Tomcat serve/listen to one more port?
> 
> wondering if copy-n-paste the connector section
> in server.xml and change the port value is enough

That's usually all that's needed for the <Connector> portion.

> Did you mean/imply that even if I manage to "connect" 
> Tomcat to the port I wanted, but if I don't use virtual
> hosts, both connectors would just serve the same webpages?

Correct; the <Host> element is equivalent to a web site, the <Connector>s just feed the <Host>s, based on the name and <Alias>.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to make Tomcat serve/listen to one more port?

Posted by Je suis la poubelle <la...@gmail.com>.
     Thanks for your reply.

     I'm still struggling to understand the syntax of configuring another
connector..... wondering if copy-n-paste the connector section in server.xml
and change the port value is enough.... too much things to read.... need
some filter to filter out unnecessary thing and just give me the essential
thing to understand for the current problem....

     Did you mean/imply that even if I manage to "connect" Tomcat to the
port I wanted, but if I don't use virtual hosts, both connectors would just
serve the same webpages?


On Thu, Mar 19, 2009 at 2:24 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Je suis la poubelle [mailto:lapsap7@gmail.com]
> > Subject: How to make Tomcat serve/listen to one more port?
> >
> > Is it possible o make it listen to one more port,
> > eg 12345, to serve HTTP?
>
> Just configure another connector for whatever ports you want.
>
> > it's suppose to serve a totally different web site at this new port.
>
> You'll want to utilize multiple <Host> elements:
> http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
>
> Set an <Alias> for each <Host> to the string value of the appropriate IP
> address to catch requests coming in using that rather than the DNS name of
> each host.
>

RE: How to make Tomcat serve/listen to one more port?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Je suis la poubelle [mailto:lapsap7@gmail.com] 
> Subject: How to make Tomcat serve/listen to one more port?
> 
> Is it possible o make it listen to one more port, 
> eg 12345, to serve HTTP?

Just configure another connector for whatever ports you want.

> it's suppose to serve a totally different web site at this new port.

You'll want to utilize multiple <Host> elements:
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html

Set an <Alias> for each <Host> to the string value of the appropriate IP address to catch requests coming in using that rather than the DNS name of each host.

> But I think it's quite a waste of resource to run an 
> additional IIS6;

Absolutely.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org