如何让 Jetty 网络服务器监听 80 端口?

Jon*_*nas 14 webserver

我想使用 Jetty 作为网络服务器。

我已经编辑了配置文件/etc/default/jetty并设置了:

# 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
Run Code Online (Sandbox Code Playgroud)

现在我可以访问 Jetty 网络服务器,http://192.168.1.10:8080但我想让 Jetty 监听端口 80。

我在同一个配置文件中尝试过这个设置:

# The network port used by Jetty
JETTY_PORT=80
Run Code Online (Sandbox Code Playgroud)

然后重新启动Jetty,sudo service jetty restart但它不起作用。

如何更改以便 Jetty 网络服务器侦听端口 80?

the*_*cer 8

您将需要编辑该/etc/jetty/jetty.xml文件。找一段说:

<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>
Run Code Online (Sandbox Code Playgroud)

jetty.port属性更改80为如下:

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

重启码头。那应该这样做。


由于上述方法对 OP 不起作用,并且不鼓励以 root 身份运行,因此有一种替代方法,如本文档中所述