You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Raymond Reid <rt...@ritvax.isc.rit.edu> on 2001/09/13 16:16:10 UTC

Can I configure Tomcat to accept HTTP requests from remote machines?

Can I configure Tomcat to accept http requests from remote IP addresses
without running another web server at the same time? I
currently have Tomcat 3.2.3 installed on NT 4.0 Service pack 6.  After
configuring Tomcat, I can enter http://localhost8080
into the location field in my browser and see the welcome page.  But
when I try to access the same page from a
different computer using the IP address of the machine I have Tomcat
running on, the page won't come up.

Do I need to be running Apache with Tomcat to access pages remotely?  If
someone could please point me in the right
direction, I would really appreciate it.

Thanks,
Ray


RE: Getting Tomcat's Port# in Servlet (using mod_jk)

Posted by Jan Labanowski <jk...@osc.edu>.
If this is the requirement, and you cannot do what I suggest (i.e., 
make symbolic links, and only have copies of web.xml files),
then you, in my humble opinion, do not have a chance... Jump from the bridge
or write your own connectors which will be adding fields to your request
header...

Jan

On Thu, 13 Sep 2001, Tony Vinayak wrote:

> Jan,
> 
> All my workers are running on the same box on different ports. They are all
> defined in the $TOMCAT_HOME/conf/workers.properties file, and they all share
> the webapps deployed under $TOMCAT_HOME/webapps. So there is only ONE copy
> of each deployed webapp with its own web.xml.
> 
> - Tony
> 
> -----Original Message-----
> From: Jan Labanowski [mailto:jkl@osc.edu]
> Sent: Thursday, September 13, 2001 2:07 PM
> To: Tony Vinayak
> Cc: Jan Labanowski; tomcat-user@jakarta.apache.org
> Subject: RE: Getting Tomcat's Port# in Servlet (using mod_jk)
> 
> 
> I am not sure how your workers are done, but usually each worker gets its
> own
> copies of context files, or its own copy of links to the context files,
> i.e.,
> each context in each worker has its own copy of the web.xml. But I do not
> know what you are doing, so I cannot really help...
> 
> Jan
> 
> On Thu, 13 Sep 2001, Tony Vinayak wrote:
> 
> > Hmmm...I am actually letting the "loadbalancer" worker handle the actual
> > allocation of the ajp13 worker (and hence the port#), so I can't hard-code
> > the port# in my web.xml.
> >
> > What I really want to accomplish is to be able to tell within my servlet
> > *which* Tomcat worker is handling it. Port# was the first thought as a
> > unique identifier; anything else I could use ??
> >
> > regards,
> > Tony
> >
> > -----Original Message-----
> > From: Jan Labanowski [mailto:jkl@osc.edu]
> > Sent: Thursday, September 13, 2001 12:17 PM
> > To: tomcat-user@jakarta.apache.org; Jan Labanowski;
> > tvinayak@covalent.net
> > Subject: Re: Getting Tomcat's Port# in Servlet (using mod_jk)
> >
> >
> > >From what I know, you cannot, but you can put the ports in the
> > context parameters in web.xml and get these parameters from within
> servlets
> > and JSP.
> >   <context-param>
> >     <param-name>connectorPort</param-name>
> >     <param-value>8007</param-value>
> >   </context-param>
> >
> > which you can retrieve from a servlet by calling:
> >
> >   getServletContext().getInitParameter("connectorPort");
> > or
> >   Connector port is <%= application.getInitParameter("connectorPort") %>
> > in JSP
> >
> > The connectors are not part of the spec, and you can only get this
> > information by modifying the Tomcat itself and adding methods which could
> > retrieve this information. Of course it would be totally unstandard and
> > unportable (but in a sense, connectors are not standard anyhow), and
> > I am not even sure how you could get to this information easily, since the
> > your classloader does not know about Tomcat classes in the
> > org.apache.tomcat.service.whatever... You could probably make them write
> > something to some static bean where you can get it, but again... This is
> > for gurus to tell us, since I would be rediscovering the wheel going
> through
> > the Tomcat source...
> >
> > Jan
> >
> > On Thu, 13 Sep 2001, Tony Vinayak wrote:
> >
> > > Greetings,
> > >
> > > Am using Tomcat 3.2 with mod_jk and Apache 1.3.20
> > >
> > > In my servlet, doing request.getServerPort() tells me the port on which
> > > Apache is listening (e.g. 80). How can I get to the Port on which Tomcat
> > > connector (ajp13) is listening (e.g. 8007) ??
> > >
> > > regards,
> > > Tony
> > >
> >
> > Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
> > Ohio Supercomputer Center    |    Internet: jkl@osc.edu
> > 1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
> > Columbus, OH 43212-1163      |    http://www.osc.edu/
> >
> >
> 
> Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
> Ohio Supercomputer Center    |    Internet: jkl@osc.edu
> 1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
> Columbus, OH 43212-1163      |    http://www.osc.edu/
> 
> 

Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
Ohio Supercomputer Center    |    Internet: jkl@osc.edu 
1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
Columbus, OH 43212-1163      |    http://www.osc.edu/


RE: Getting Tomcat's Port# in Servlet (using mod_jk)

Posted by Tony Vinayak <tv...@covalent.net>.
Jan,

All my workers are running on the same box on different ports. They are all
defined in the $TOMCAT_HOME/conf/workers.properties file, and they all share
the webapps deployed under $TOMCAT_HOME/webapps. So there is only ONE copy
of each deployed webapp with its own web.xml.

- Tony

-----Original Message-----
From: Jan Labanowski [mailto:jkl@osc.edu]
Sent: Thursday, September 13, 2001 2:07 PM
To: Tony Vinayak
Cc: Jan Labanowski; tomcat-user@jakarta.apache.org
Subject: RE: Getting Tomcat's Port# in Servlet (using mod_jk)


I am not sure how your workers are done, but usually each worker gets its
own
copies of context files, or its own copy of links to the context files,
i.e.,
each context in each worker has its own copy of the web.xml. But I do not
know what you are doing, so I cannot really help...

Jan

On Thu, 13 Sep 2001, Tony Vinayak wrote:

> Hmmm...I am actually letting the "loadbalancer" worker handle the actual
> allocation of the ajp13 worker (and hence the port#), so I can't hard-code
> the port# in my web.xml.
>
> What I really want to accomplish is to be able to tell within my servlet
> *which* Tomcat worker is handling it. Port# was the first thought as a
> unique identifier; anything else I could use ??
>
> regards,
> Tony
>
> -----Original Message-----
> From: Jan Labanowski [mailto:jkl@osc.edu]
> Sent: Thursday, September 13, 2001 12:17 PM
> To: tomcat-user@jakarta.apache.org; Jan Labanowski;
> tvinayak@covalent.net
> Subject: Re: Getting Tomcat's Port# in Servlet (using mod_jk)
>
>
> >From what I know, you cannot, but you can put the ports in the
> context parameters in web.xml and get these parameters from within
servlets
> and JSP.
>   <context-param>
>     <param-name>connectorPort</param-name>
>     <param-value>8007</param-value>
>   </context-param>
>
> which you can retrieve from a servlet by calling:
>
>   getServletContext().getInitParameter("connectorPort");
> or
>   Connector port is <%= application.getInitParameter("connectorPort") %>
> in JSP
>
> The connectors are not part of the spec, and you can only get this
> information by modifying the Tomcat itself and adding methods which could
> retrieve this information. Of course it would be totally unstandard and
> unportable (but in a sense, connectors are not standard anyhow), and
> I am not even sure how you could get to this information easily, since the
> your classloader does not know about Tomcat classes in the
> org.apache.tomcat.service.whatever... You could probably make them write
> something to some static bean where you can get it, but again... This is
> for gurus to tell us, since I would be rediscovering the wheel going
through
> the Tomcat source...
>
> Jan
>
> On Thu, 13 Sep 2001, Tony Vinayak wrote:
>
> > Greetings,
> >
> > Am using Tomcat 3.2 with mod_jk and Apache 1.3.20
> >
> > In my servlet, doing request.getServerPort() tells me the port on which
> > Apache is listening (e.g. 80). How can I get to the Port on which Tomcat
> > connector (ajp13) is listening (e.g. 8007) ??
> >
> > regards,
> > Tony
> >
>
> Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
> Ohio Supercomputer Center    |    Internet: jkl@osc.edu
> 1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
> Columbus, OH 43212-1163      |    http://www.osc.edu/
>
>

Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
Ohio Supercomputer Center    |    Internet: jkl@osc.edu
1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
Columbus, OH 43212-1163      |    http://www.osc.edu/



RE: Getting Tomcat's Port# in Servlet (using mod_jk)

Posted by Jan Labanowski <jk...@osc.edu>.
I am not sure how your workers are done, but usually each worker gets its own
copies of context files, or its own copy of links to the context files, i.e., 
each context in each worker has its own copy of the web.xml. But I do not
know what you are doing, so I cannot really help...

Jan

On Thu, 13 Sep 2001, Tony Vinayak wrote:

> Hmmm...I am actually letting the "loadbalancer" worker handle the actual
> allocation of the ajp13 worker (and hence the port#), so I can't hard-code
> the port# in my web.xml.
> 
> What I really want to accomplish is to be able to tell within my servlet
> *which* Tomcat worker is handling it. Port# was the first thought as a
> unique identifier; anything else I could use ??
> 
> regards,
> Tony
> 
> -----Original Message-----
> From: Jan Labanowski [mailto:jkl@osc.edu]
> Sent: Thursday, September 13, 2001 12:17 PM
> To: tomcat-user@jakarta.apache.org; Jan Labanowski;
> tvinayak@covalent.net
> Subject: Re: Getting Tomcat's Port# in Servlet (using mod_jk)
> 
> 
> >From what I know, you cannot, but you can put the ports in the
> context parameters in web.xml and get these parameters from within servlets
> and JSP.
>   <context-param>
>     <param-name>connectorPort</param-name>
>     <param-value>8007</param-value>
>   </context-param>
> 
> which you can retrieve from a servlet by calling:
> 
>   getServletContext().getInitParameter("connectorPort");
> or
>   Connector port is <%= application.getInitParameter("connectorPort") %>
> in JSP
> 
> The connectors are not part of the spec, and you can only get this
> information by modifying the Tomcat itself and adding methods which could
> retrieve this information. Of course it would be totally unstandard and
> unportable (but in a sense, connectors are not standard anyhow), and
> I am not even sure how you could get to this information easily, since the
> your classloader does not know about Tomcat classes in the
> org.apache.tomcat.service.whatever... You could probably make them write
> something to some static bean where you can get it, but again... This is
> for gurus to tell us, since I would be rediscovering the wheel going through
> the Tomcat source...
> 
> Jan
> 
> On Thu, 13 Sep 2001, Tony Vinayak wrote:
> 
> > Greetings,
> >
> > Am using Tomcat 3.2 with mod_jk and Apache 1.3.20
> >
> > In my servlet, doing request.getServerPort() tells me the port on which
> > Apache is listening (e.g. 80). How can I get to the Port on which Tomcat
> > connector (ajp13) is listening (e.g. 8007) ??
> >
> > regards,
> > Tony
> >
> 
> Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
> Ohio Supercomputer Center    |    Internet: jkl@osc.edu
> 1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
> Columbus, OH 43212-1163      |    http://www.osc.edu/
> 
> 

Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
Ohio Supercomputer Center    |    Internet: jkl@osc.edu 
1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
Columbus, OH 43212-1163      |    http://www.osc.edu/


RE: Getting Tomcat's Port# in Servlet (using mod_jk)

Posted by Tony Vinayak <tv...@covalent.net>.
Hmmm...I am actually letting the "loadbalancer" worker handle the actual
allocation of the ajp13 worker (and hence the port#), so I can't hard-code
the port# in my web.xml.

What I really want to accomplish is to be able to tell within my servlet
*which* Tomcat worker is handling it. Port# was the first thought as a
unique identifier; anything else I could use ??

regards,
Tony

-----Original Message-----
From: Jan Labanowski [mailto:jkl@osc.edu]
Sent: Thursday, September 13, 2001 12:17 PM
To: tomcat-user@jakarta.apache.org; Jan Labanowski;
tvinayak@covalent.net
Subject: Re: Getting Tomcat's Port# in Servlet (using mod_jk)


>>From what I know, you cannot, but you can put the ports in the
context parameters in web.xml and get these parameters from within servlets
and JSP.
  <context-param>
    <param-name>connectorPort</param-name>
    <param-value>8007</param-value>
  </context-param>

which you can retrieve from a servlet by calling:

  getServletContext().getInitParameter("connectorPort");
or
  Connector port is <%= application.getInitParameter("connectorPort") %>
in JSP

The connectors are not part of the spec, and you can only get this
information by modifying the Tomcat itself and adding methods which could
retrieve this information. Of course it would be totally unstandard and
unportable (but in a sense, connectors are not standard anyhow), and
I am not even sure how you could get to this information easily, since the
your classloader does not know about Tomcat classes in the
org.apache.tomcat.service.whatever... You could probably make them write
something to some static bean where you can get it, but again... This is
for gurus to tell us, since I would be rediscovering the wheel going through
the Tomcat source...

Jan

On Thu, 13 Sep 2001, Tony Vinayak wrote:

> Greetings,
>
> Am using Tomcat 3.2 with mod_jk and Apache 1.3.20
>
> In my servlet, doing request.getServerPort() tells me the port on which
> Apache is listening (e.g. 80). How can I get to the Port on which Tomcat
> connector (ajp13) is listening (e.g. 8007) ??
>
> regards,
> Tony
>

Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
Ohio Supercomputer Center    |    Internet: jkl@osc.edu
1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
Columbus, OH 43212-1163      |    http://www.osc.edu/



Re: Getting Tomcat's Port# in Servlet (using mod_jk)

Posted by Jan Labanowski <jk...@osc.edu>.
>From what I know, you cannot, but you can put the ports in the
context parameters in web.xml and get these parameters from within servlets
and JSP.
  <context-param>
    <param-name>connectorPort</param-name>
    <param-value>8007</param-value>
  </context-param>

which you can retrieve from a servlet by calling:

  getServletContext().getInitParameter("connectorPort");
or
  Connector port is <%= application.getInitParameter("connectorPort") %>
in JSP

The connectors are not part of the spec, and you can only get this
information by modifying the Tomcat itself and adding methods which could
retrieve this information. Of course it would be totally unstandard and
unportable (but in a sense, connectors are not standard anyhow), and
I am not even sure how you could get to this information easily, since the
your classloader does not know about Tomcat classes in the
org.apache.tomcat.service.whatever... You could probably make them write
something to some static bean where you can get it, but again... This is
for gurus to tell us, since I would be rediscovering the wheel going through
the Tomcat source...

Jan

On Thu, 13 Sep 2001, Tony Vinayak wrote:

> Greetings,
> 
> Am using Tomcat 3.2 with mod_jk and Apache 1.3.20
> 
> In my servlet, doing request.getServerPort() tells me the port on which
> Apache is listening (e.g. 80). How can I get to the Port on which Tomcat
> connector (ajp13) is listening (e.g. 8007) ??
> 
> regards,
> Tony
> 

Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
Ohio Supercomputer Center    |    Internet: jkl@osc.edu 
1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
Columbus, OH 43212-1163      |    http://www.osc.edu/


Getting Tomcat's Port# in Servlet (using mod_jk)

Posted by Tony Vinayak <tv...@covalent.net>.
Greetings,

Am using Tomcat 3.2 with mod_jk and Apache 1.3.20

In my servlet, doing request.getServerPort() tells me the port on which
Apache is listening (e.g. 80). How can I get to the Port on which Tomcat
connector (ajp13) is listening (e.g. 8007) ??

regards,
Tony


Re: Can I configure Tomcat to accept HTTP requests from remote machines?

Posted by Elm Gysel <el...@dateq.be>.
heya!

You don't need to run apache, but its recommended.
here are pro's and contra's from :
http://jakarta.apache.org/tomcat/tomcat-3.2-doc/tomcat-apache-howto.html#coo
peration_need
      1.    Tomcat is not as fast as Apache when it comes to static pages.
      2.    Tomcat is not as configurable as Apache.
      3.    Tomcat is not as robust as Apache.
      4.    Tomcat may not address many sites' need for functionality found
only in Apache modules (e.g. Perl, PHP, etc.).

  For all these reasons it is recommended that real-world sites use an
industrial-strength web server, such as Apache, for serving static content,
and use Tomcat as a Servlet/JSP add-on.

  Cheers!

  Elm

----- Original Message -----
From: "Raymond Reid" <rt...@ritvax.isc.rit.edu>
To: <to...@jakarta.apache.org>
Sent: Thursday, September 13, 2001 4:16 PM
Subject: Can I configure Tomcat to accept HTTP requests from remote
machines?


> Can I configure Tomcat to accept http requests from remote IP addresses
> without running another web server at the same time? I
> currently have Tomcat 3.2.3 installed on NT 4.0 Service pack 6.  After
> configuring Tomcat, I can enter http://localhost8080
> into the location field in my browser and see the welcome page.  But
> when I try to access the same page from a
> different computer using the IP address of the machine I have Tomcat
> running on, the page won't come up.
>
> Do I need to be running Apache with Tomcat to access pages remotely?  If
> someone could please point me in the right
> direction, I would really appreciate it.
>
> Thanks,
> Ray


RE: Can I configure Tomcat to accept HTTP requests from remote machines?

Posted by Tony Vinayak <tv...@covalent.net>.
Interesting,y, if I don't have the "inet" config line at all in my
server.xml, I can access the running Tomcat both locally and remotely
without any server.xml config change!

- Tony


-----Original Message-----
From: Peter Davison [mailto:pdavison@channelwave.com]
Sent: Thursday, September 13, 2001 10:31 AM
To: tomcat-user@jakarta.apache.org
Subject: Re: Can I configure Tomcat to accept HTTP requests from remote
machines?


Hi Ray.

"localhost" is just that - it is accessible only to the local machine.
In order to make your server accessible to other machines you need to
specify it's
IP address in the server.xml file.

In the connectors section of "server.xml" you need to replace "127.0.0.1"
with
the IP of your machine.

       <!-- Normal HTTP -->
        <Connector className="org.apache.tomcat.service.PoolTcpConnector">
            <Parameter name="handler"

value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
            <Parameter name="inet" value="127.0.0.1"/>
            <Parameter name="port" value="8080"/>
        </Connector>

Once you've done this a restarted you can access your webserver remotely by
specifying the actuall IP and port number in use.

Hope that helps.
Pete.


On Thu, 13 Sep 2001 10:16:10 -0400
Raymond Reid <rt...@ritvax.isc.rit.edu> wrote:

RR> Can I configure Tomcat to accept http requests from remote IP addresses
RR> without running another web server at the same time? I
RR> currently have Tomcat 3.2.3 installed on NT 4.0 Service pack 6.  After
RR> configuring Tomcat, I can enter http://localhost8080
RR> into the location field in my browser and see the welcome page.  But
RR> when I try to access the same page from a
RR> different computer using the IP address of the machine I have Tomcat
RR> running on, the page won't come up.
RR>
RR> Do I need to be running Apache with Tomcat to access pages remotely?  If
RR> someone could please point me in the right
RR> direction, I would really appreciate it.
RR>
RR> Thanks,
RR> Ray


Re: Can I configure Tomcat to accept HTTP requests from remote machines?

Posted by Peter Davison <pd...@channelwave.com>.
Hi Ray.

"localhost" is just that - it is accessible only to the local machine.
In order to make your server accessible to other machines you need to specify it's
IP address in the server.xml file.

In the connectors section of "server.xml" you need to replace "127.0.0.1" with
the IP of your machine.

       <!-- Normal HTTP -->
        <Connector className="org.apache.tomcat.service.PoolTcpConnector">
            <Parameter name="handler" 
                value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
            <Parameter name="inet" value="127.0.0.1"/>
            <Parameter name="port" value="8080"/>
        </Connector>

Once you've done this a restarted you can access your webserver remotely by 
specifying the actuall IP and port number in use.

Hope that helps.
Pete.


On Thu, 13 Sep 2001 10:16:10 -0400
Raymond Reid <rt...@ritvax.isc.rit.edu> wrote:

RR> Can I configure Tomcat to accept http requests from remote IP addresses
RR> without running another web server at the same time? I
RR> currently have Tomcat 3.2.3 installed on NT 4.0 Service pack 6.  After
RR> configuring Tomcat, I can enter http://localhost8080
RR> into the location field in my browser and see the welcome page.  But
RR> when I try to access the same page from a
RR> different computer using the IP address of the machine I have Tomcat
RR> running on, the page won't come up.
RR> 
RR> Do I need to be running Apache with Tomcat to access pages remotely?  If
RR> someone could please point me in the right
RR> direction, I would really appreciate it.
RR> 
RR> Thanks,
RR> Ray

Re: Can I configure Tomcat to accept HTTP requests from remote machines?

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
http://localhost:8080 will just be an alias for http://127.0.0.1:8080 - so
doing it on another computer means that you're just trying to request the
computer that you are doing the request on.  Instead - find out what the
ip address is, using ipconfig, or winipcfg (I can never rememeber which is
used where)... and use http://192.168.0.1:8080 - replacing 192.168.0.1
witht he IP address.

hth
dim

On Thu, 13 Sep 2001, Raymond Reid wrote:

> Can I configure Tomcat to accept http requests from remote IP addresses
> without running another web server at the same time? I
> currently have Tomcat 3.2.3 installed on NT 4.0 Service pack 6.  After
> configuring Tomcat, I can enter http://localhost8080
> into the location field in my browser and see the welcome page.  But
> when I try to access the same page from a
> different computer using the IP address of the machine I have Tomcat
> running on, the page won't come up.
> 
> Do I need to be running Apache with Tomcat to access pages remotely?  If
> someone could please point me in the right
> direction, I would really appreciate it.
> 
> Thanks,
> Ray
> 
> 


RE: Can I configure Tomcat to accept HTTP requests from remote machines?

Posted by Tony Vinayak <tv...@covalent.net>.
I presume you are able to ping the IP addr from the other computer. If you
can access Tomcat locally (localhost:8080), you should most certainly be
able to access it remotely (e.g. http://192.163.1.100:8080). If not already,
don't forget to suffix the IP addr with the port # (8080)

IF the above still doesn't work, what error do you get?

cheers,
Tony

-----Original Message-----
From: Raymond Reid [mailto:rtr2935@ritvax.isc.rit.edu]
Sent: Thursday, September 13, 2001 10:16 AM
To: tomcat-user@jakarta.apache.org
Subject: Can I configure Tomcat to accept HTTP requests from remote
machines?


Can I configure Tomcat to accept http requests from remote IP addresses
without running another web server at the same time? I
currently have Tomcat 3.2.3 installed on NT 4.0 Service pack 6.  After
configuring Tomcat, I can enter http://localhost8080
into the location field in my browser and see the welcome page.  But
when I try to access the same page from a
different computer using the IP address of the machine I have Tomcat
running on, the page won't come up.

Do I need to be running Apache with Tomcat to access pages remotely?  If
someone could please point me in the right
direction, I would really appreciate it.

Thanks,
Ray