Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
you can change it also from start.ini (jetty root), there you have --> jetty.port - line, uncomment and give it a value (default is 8080) –  Rodislav Dec 19 '13 at 8:21
add comment

2 Answers

up vote 6 down vote accepted

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.

share|improve this answer
    
This doesn't work. I also checked with sudo netstat -nlp but Jetty is not listed. –  Jonas Mar 18 '11 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. –  theTuxRacer Mar 18 '11 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. –  theTuxRacer Mar 18 '11 at 14:05
    
Additionally take a look at: running jetty as non root user. –  theTuxRacer Mar 18 '11 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 '11 at 14:09
show 3 more comments

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.