14

I would like to use Jetty as a webserver.

I have edited the configuration file at /etc/default/jetty and set:

# change to 0 to allow Jetty start
NO_START=0

# Listen to connections from this network host
# Use 0.0.0.0 as host to accept all connections.
JETTY_HOST=0.0.0.0

Now I can reach the Jetty webserver at http://192.168.1.10:8080 but I would like to have Jetty listening on port 80.

I have tried this setting in the same configuration file:

# The network port used by Jetty
JETTY_PORT=80

and then restart Jetty with sudo service jetty restart but it doesn't work.

How can I change so that the Jetty webserver is listening on port 80?

2

3 Answers 3

8

You will need to edit the /etc/jetty/jetty.xml file. Look for a paragraph that says:

<Call name="addConnector">
      <Arg>
          <New class="org.mortbay.jetty.nio.SelectChannelConnector">
            <Set name="host"><SystemProperty name="jetty.host" /></Set>
            <Set name="port"><SystemProperty name="jetty.port" default="8090"/></Set>
            <Set name="maxIdleTime">30000</Set>
            <Set name="Acceptors">2</Set>
            <Set name="statsOn">false</Set>
            <Set name="confidentialPort">8443</Set>
        <Set name="lowResourcesConnections">5000</Set>
        <Set name="lowResourcesMaxIdleTime">5000</Set>
          </New>
      </Arg>
    </Call>

Change the jetty.port Property to 80 as follows:

<Set name="port"><SystemProperty name="jetty.port" default="80"/></Set>

Restart jetty. That should do it.


Since the above method did not work for OP, and running as root is discouraged, there is an alternative method, as mentioned in this document.

8
  • This doesn't work. I also checked with sudo netstat -nlp but Jetty is not listed.
    – Jonas
    Mar 18, 2011 at 13:41
  • It might be because jetty is not running as root. I am trying out a setting, and will post in a while. Mar 18, 2011 at 13:55
  • I was able to get the default page by running sudo java -jar start.jar from /usr/share/jetty. I also configured the /etc/jetty/jetty-setuid.xml to start as privileged user. Mar 18, 2011 at 14:05
  • Additionally take a look at: running jetty as non root user. Mar 18, 2011 at 14:07
  • 1
    I run sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 and now it works fine. Thanks!
    – Jonas
    Mar 18, 2011 at 14:09
2

I am using Jetty 9. In the file start.ini you can find and modify the property jetty.port. Then you have to restart jetty.service.

1
  • 1
    It might be useful if you expand your answer by specifying the location of the start.ini file, the line in start.ini that has to be modified, and the modified text that has to be used.
    – CentaurusA
    Sep 10, 2018 at 23:38
1

Neatest way to do it is with xinetd (you may need to install it on your server first) see here: http://wiki.eclipse.org/Jetty/Howto/Port80

You must log in to answer this question.

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