全部,
我尝试在端口 80 上设置 jetty,但它给出异常,提示权限被拒绝,如下所示。我已将 jetty 设置为使用 setuid,并配置了 start.ini,如下所示:
OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations,jta,jdbc,setuid
(以下为start.ini中的第一个配置文件)
etc/jetty-setuid.xml
以及包含非root用户的用户名和组名的jetty-setuid.xml文件。
2012-07-03 15:29:02.411:INFO:oejdp.ScanningAppProvider:Deployment monitor /opt/jetty-hightide-8.1.3.v20120416/contexts at interval 1
2012-07-03 15:29:02.454:WARN:oejuc.AbstractLifeCycle:FAILED [email protected]:80: java.net.SocketException: Permission denied
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:182)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:311)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:260)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.Server.doStart(Server.java:273)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1215)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
2012-07-03 15:29:02.455:WARN:oejuc.AbstractLifeCycle:FAILED org.eclipse.jetty.server.Server@66da9ea4: java.net.SocketException: Permission denied
java.net.SocketException: Permission denied
答案1
1024 以下的端口只能由超级用户绑定。您可以以超级用户 (root) 身份运行 jetty,或将其配置为使用 1024 以上的端口(例如 8080,这通常用于基于 Java 的应用服务器)。如果您希望不惜一切代价通过端口 80 访问它,您可以将 Apache 服务器设置为将请求转发(或“反向代理”)到 Jetty。此处有明确记录:
http://docs.codehaus.org/display/JETTY/Configuring+mod_proxy
答案2
放弃 Apache 转而使用 Tomcat,转而使用 Nginx 和那些简单的行
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/example.log;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}