tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
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 <goldin+tomcat@pitt.edu>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: 'Tomcat Users List' <tomcat-user@jakarta.apache.org>
> 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 a.mycompany.com answers only on IP address 10.0.0.1 port 8080
* Host b.mycompany.com answers only on IP address 10.0.0.2 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="10.0.0.1" .../>
      <Engine name="Host A Engine" defaultHost="a.mycompany.com" ...>
        <Host name="a.mycompany.com" ...>
          <!-- <Context> entries for your webapps go here -->
        </Host>
      </Engine>
    </Service>

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

</Server>

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
>

Craig


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message