tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: redirection
Date Wed, 01 Apr 2009 15:25:41 GMT
Melanie Pfefer wrote:
> Hello
> I have a tomcat server running on port 8080.
> users need to create a dns alias which is on port 80. redirection cannot be done on DNS
level of course.
> do you have any idea how to achieve this in tomcat. For example:
> http://siroe redirects to http://machineX:8080 that is a tomcat application?
Hi Melanie.
Since by now, after all these ponderous answers, you might be pretty 
confused as to what to do, let me restart from the beginning.

First, you can configure Tomcat to accept requests on port 80, instead 
of, or in addition to, port 8080.
That is easy, and you would do it in principle by changing in the 
server.xml file, the existing <Connector ... port="8080"> to <Connector 
... port="80">.  That's almost it.
The only catch is that in order for this to work, this Tomcat would need 
to run as user root, because only user root can run a process that opens 
a listening port <= 1024.

If this Tomcat cannot run as root, then there is a workaround : you can 
use something called jsvc, which is like a "wrapper" process which 
starts as root, opens port 80 for Tomcat, then runs Tomcat as a non-root 
user.  That allows Tomcat to run as a non-root user, and to still listen 
on port 80.

If none of the above is possible, then you could indeed run an Apache 
httpd "in front of" your Tomcat.  The Apache httpd (maybe one that is 
there already), can accept requests on port 80, look at the request, 
determine that it is one that Tomcat should handle, and pass it to the 
back-end Tomcat on another port.  This can be done in several ways :

1) the front-end Apache httpd, which listens on port 80, can just act as 
a HTTP proxy, and pass the appropriate requests to the back-end Tomcat 
on the Tomcat HTTP port 8080.
2) the front-end Apache can act as an AJP proxy, and pass requests to 
Tomcat using the AJP protocol.  This requires adding another <Connector> 
to Tomcat, to listen for requests that use that protocol.
There are 2 sub-cases of this :
2a) using (at the Apache httpd level), a module called mod_proxy_ajp
2b) using (at the Apache httpd level), a module called mod_jk
(In both cases, you can choose the port Tomcat uses to listen for that)

If none of the above is possible or practical, then there are still 
other solutions, using other methods in software/hardware.

Roughly, the above is in order of increasing complexity.

The issue here is not to find a solution (there are many), but to find 
the solution that is the easiest and best-adapted to your problem.

Your initial post above is not very clear as to why you need this.
Tell us a bit more about your real problem and we could probably do 
better at recommending an appropriate solution to you.

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

View raw message