3

I'm curious what techniques you Linux admin gods are using to manage your Jetty deployments. I come from a Windows Server background so I'm still getting used to all of this. I've been looking for a good solution for deploying Jetty instances as port 80 on a Linux installation.

So far I've seen this thread which allows Jetty to run as a daemon:

http://jira.codehaus.org/browse/JETTY-458

And I've seen this thread which talks about alternates for setting up on port 80:

http://wiki.eclipse.org/Jetty/Howto/Port80

These all seemed kind of hacky. Surely there is a relatively standard way of deploying a web server like Jetty on Linux. I'm currently using CentOS 5.5 but open to other distros.

Thanks in advance.

1
  • Thanks guys. Both answers were helpful to the task. I gave the solution to @Redmumba since the daemonize part wasn't mentioned in the links above.
    – McKAMEY
    Feb 9, 2011 at 21:20

2 Answers 2

2

Unfortunately, Java processes tend not to daemonize as well as other languages. For Jetty, you'll want to use something like daemonize to launch and manage the process.

Edit - some additional details:

After building daemonize (as per instructions in above link), the command line parameters are explained in the generated file daemonize.html. Test it out from the launch command to ensure it works as expected.

Then to launch Jetty at startup, add the daemonize command to an init shell script (e.g., for CentOS/RHEL append /etc/rc.d/rc.local). For example:

#!/bin/bash
#...other startup commands

/path-to/daemonize -c /path-to/jetty/ -p pid.txt -e error.log -o console.log -a /usr/bin/java -jar start.jar
1
  • Thanks. I like the simplicity of the daemonize approach. Plus it does not appear to be limited to Java.
    – McKAMEY
    Feb 8, 2011 at 21:20
1

I would put an Apache2 proxy in front of an application server. Apache2 has a specific module designed for this. It adds the appropriate headers to the request for your application to identify the remote user. Apache2 can be used to serve static content, and only pass application requests to the application server.

Windows does not implement privileged ports (ports less than 1024). Other than running Jetty as root, some technique is required bind port 80 as root and pass the data to Jetty. Apache2 uses setuid after binding the port so that the process handling a request does not have root access to your system.

The sites you have found show some of the options:

  • Redirect port 80 to an unprivileged port using iptables or ipchains.
  • Use a wrapper to bind port 80 and then execute a setuid command before transferring control to Jetty as a daemon. Java does not provide direct access to setuid, so native libraries are required.
  • Redirect port 80 to an unprivileged port using xinetd. I would use iptables instead.
1
  • 1
    Thanks. I added this to /etc/rc.d/rc.local: /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 and it forwards all external port 80 traffic to my Jetty daemon on port 8080.
    – McKAMEY
    Feb 9, 2011 at 21:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .