16 September 2008 - 18:08tomcat on port 80
You might know the situation: You’d like to run tomcat from a privileged port, but the bloody thing just won’t start. Of course, it’s java-specific. Usually, a daemon gets its port from root. Not with Java. Your possibilities are therefore somewhat cruel. let us think about the options…
- run it as root. that’s ugly and not secure, but quick & dirty and just works.
- use jsvc. this will force you to mess up the funky startup script.
- write a C programm or use iptables. The C-thing doesn’t work (for me). iptables… mmmh…
terrible, didn’t I tell you? Well… there’s another way:
use the good-old xinetd. the way is described here (search for xinetd) and the essence comes as followed.
If you want to set up Tomcat to handle port 80 requests on your system, you’ll need to add a xinetd configuration file for this purpose. Assuming xinetd is installed with the usual paths, you can do this by adding a file (as user root) to the /etc/xinetd.d directory. Listing 1 gives a sample configuration file for Tomcat.
Listing 1. xinetd redirect configuration
# Redirects any requests on port 80
# to port 8080 (where Tomcat is listening)
service tomcat
{
socket_type = stream
protocol = tcp
user = root
wait = no
port = 80
redirect = localhost 8080
disable = no
}After you’ve added the configuration file, you’ll need to restart xinetd to actually activate the redirection.
cool, eh?
2 Comments
Categories: Linux, Software, Webserver, howto
Tags: gentoo webserver tomcat howto non-root