tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject RE: tomcat stand alone and multiple ips.
Date Thu, 01 Nov 2001 01:42:21 GMT

On Wed, 31 Oct 2001, Ilya Goldin wrote:

> Date: Wed, 31 Oct 2001 20:00:17 -0500
> From: Ilya Goldin <>
> Reply-To: Tomcat Users List <>
> To: 'Tomcat Users List' <>
> Subject: RE: tomcat stand alone and multiple ips.
> > > How can I attach an instance of tomcat to a specific ip?
> > Right now it
> > > monitors port 80 on all ips on the box.  Can I have one instance of
> > > tomcat host multiple 'virtual' sites or do I need
> > > to run seperate instances of tomcat listening to different ips?
> >
> > $TOMCAT_HOME\webapps\tomcat-docs\config\host.html
> >
> > Looks like you can have mutiple virtual hosts for one
> > instance of Tomcat.
> OK, fine -- but that's not what I want. I want exactly one virtual host
> answering to exactly one domain name/ip request. If I have a machine
> that binds to several different domain names and IPs, I only want Tomcat
> to answer on ONE of those domain names. By default, it answers on all of
> them.

That's actually possible as well (with Tomcat 4) -- it just takes a little
more work.  Let's assume that you want the following:

* Host answers only on IP address port 8080
* Host answers only on IP address port 8080

The key is that you have to set up a different <Service> for each
Connector.  A skeleton of your server.xml file would look like this:

  <Server ...>

    <Service name="Host A Service">
      <Connector port="8080" address="" .../>
      <Engine name="Host A Engine" defaultHost="" ...>
        <Host name="" ...>
          <!-- <Context> entries for your webapps go here -->

    <Service name="Host B Service">
      <Connector port="8080" address="" .../>
      <Engine name="Host B Engine" defaultHost="" ...>
        <Host name="" ...>
          <!-- <Context> entries for your webapps go here -->


As variations on this theme, you can still have more than one <Connector>
within a service, as well as more than one name-based virtual host.  The
important part is that the connector only listens on the IP address that
you specify.

> In a way, I want a valve or filter to complement the existing Remote
> Address Filter and Remote Host Filter. While those check the source of
> the request, I want a filter that checks the explicit destination of the
> request, so that my application does not launch if the request did not
> explicitly specify its destination.

I'm not sure a filter would be sufficient -- if you want other
applications to be able to bind to other IP addresses with the same port
number, you definitely need to do something like the above.

> Is this functionality already available? Is there a workaround?

Does the multiple services approach outlined above do what you need?

> Thanks,
> ig


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message